View Javadoc
1   package fr.ifremer.dali.ui.swing.content.observation.photo;
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.decorator.DecoratorService;
27  import fr.ifremer.dali.dto.data.sampling.SamplingOperationDTO;
28  import fr.ifremer.dali.dto.referential.PhotoTypeDTO;
29  import fr.ifremer.dali.ui.swing.util.table.AbstractDaliTableModel;
30  import fr.ifremer.dali.ui.swing.util.table.DaliColumnIdentifier;
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   * Le modele pour le tableau des photos.
39   */
40  public class PhotosTableModel extends AbstractDaliTableModel<PhotosTableRowModel> {
41  
42      /**
43       * Identifiant pour la colonne mnemonique.
44       */
45      public static final DaliColumnIdentifier<PhotosTableRowModel> NAME = DaliColumnIdentifier.newId(
46      		PhotosTableRowModel.PROPERTY_NAME,
47              n("dali.property.name"),
48              n("dali.photo.name.tip"),
49              String.class,
50              true);
51      
52      /**
53       * Identifiant pour la colonne type.
54       */
55      public static final DaliColumnIdentifier<PhotosTableRowModel> TYPE = DaliColumnIdentifier.newId(
56      		PhotosTableRowModel.PROPERTY_PHOTO_TYPE,
57              n("dali.photo.type"),
58              n("dali.photo.type.tip"),
59              PhotoTypeDTO.class);
60      
61      /**
62       * Identifiant pour la colonne legende.
63       */
64      public static final DaliColumnIdentifier<PhotosTableRowModel> CAPTION = DaliColumnIdentifier.newId(
65      		PhotosTableRowModel.PROPERTY_CAPTION,
66              n("dali.photo.caption"),
67              n("dali.photo.caption.tip"),
68              String.class);
69      
70      /**
71       * Identifiant pour la colonne date.
72       */
73      public static final DaliColumnIdentifier<PhotosTableRowModel> DATE = DaliColumnIdentifier.newId(
74      		PhotosTableRowModel.PROPERTY_DATE,
75              n("dali.property.date"),
76              n("dali.photo.date.tip"),
77              Date.class,
78              true);
79      
80      /**
81       * Identifiant pour la colonne prelevement.
82       */
83      public static final DaliColumnIdentifier<PhotosTableRowModel> SAMPLING_OPERATION = DaliColumnIdentifier.newId(
84      		PhotosTableRowModel.PROPERTY_SAMPLING_OPERATION,
85              n("dali.property.samplingOperation"),
86              n("dali.photo.samplingOperation.tip"),
87              SamplingOperationDTO.class,
88              DecoratorService.CONCAT);
89      
90      /**
91       * Identifiant pour la colonne direction.
92       */
93      public static final DaliColumnIdentifier<PhotosTableRowModel> DIRECTION = DaliColumnIdentifier.newId(
94      		PhotosTableRowModel.PROPERTY_DIRECTION,
95              n("dali.photo.direction"),
96              n("dali.photo.direction.tip"),
97              String.class);
98      
99      /**
100      * Identifiant pour la colonne chemin physique.
101      */
102     public static final DaliColumnIdentifier<PhotosTableRowModel> PATH = DaliColumnIdentifier.newId(
103     		PhotosTableRowModel.PROPERTY_PATH,
104             n("dali.photo.path"),
105             n("dali.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 SwingTableColumnModel 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 DaliColumnIdentifier<PhotosTableRowModel> getFirstColumnEditing() {
138 		return NAME;
139 	}
140 }