View Javadoc
1   package fr.ifremer.reefdb.ui.swing.content.observation.survey.measurement.grouped;
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.survey.SurveyDTO;
28  import fr.ifremer.reefdb.dto.referential.TaxonDTO;
29  import fr.ifremer.reefdb.dto.referential.TaxonGroupDTO;
30  import fr.ifremer.reefdb.ui.swing.content.observation.shared.AbstractMeasurementsGroupedTableModel;
31  import fr.ifremer.reefdb.ui.swing.content.observation.shared.AbstractMeasurementsGroupedTableUIModel;
32  import fr.ifremer.reefdb.ui.swing.util.table.ReefDbColumnIdentifier;
33  import org.jdesktop.swingx.table.TableColumnModelExt;
34  
35  import static org.nuiton.i18n.I18n.n;
36  
37  /**
38   * Le modele pour le tableau des mesures des observation (ecran observation/mesure).
39   */
40  public class SurveyMeasurementsGroupedTableModel extends AbstractMeasurementsGroupedTableModel<SurveyMeasurementsGroupedRowModel> {
41  
42      /**
43       * Identifiant pour la colonne groupe taxon.
44       */
45      public static final ReefDbColumnIdentifier<SurveyMeasurementsGroupedRowModel> TAXON_GROUP = ReefDbColumnIdentifier.newId(
46          SurveyMeasurementsGroupedRowModel.PROPERTY_TAXON_GROUP,
47          n("reefdb.property.taxonGroup.short"),
48          n("reefdb.survey.measurement.grouped.taxonGroup.tip"),
49          TaxonGroupDTO.class);
50  
51      /**
52       * Identifiant pour la colonne taxon.
53       */
54      public static final ReefDbColumnIdentifier<SurveyMeasurementsGroupedRowModel> TAXON = ReefDbColumnIdentifier.newId(
55          SurveyMeasurementsGroupedRowModel.PROPERTY_TAXON,
56          n("reefdb.property.taxon"),
57          n("reefdb.survey.measurement.grouped.taxon.tip"),
58          TaxonDTO.class,
59          DecoratorService.WITH_CITATION);
60  
61      /**
62       * Identifiant pour la colonne taxon saisi.
63       */
64      public static final ReefDbColumnIdentifier<SurveyMeasurementsGroupedRowModel> INPUT_TAXON_NAME = ReefDbColumnIdentifier.newId(
65          SurveyMeasurementsGroupedRowModel.PROPERTY_INPUT_TAXON_NAME,
66          n("reefdb.property.inputTaxon"),
67          n("reefdb.survey.measurement.grouped.inputTaxon.tip"),
68          String.class);
69  
70      /**
71       * Identifiant pour la colonne valeur.
72       */
73      public static final ReefDbColumnIdentifier<SurveyMeasurementsGroupedRowModel> COMMENT = ReefDbColumnIdentifier.newId(
74          SurveyMeasurementsGroupedRowModel.PROPERTY_COMMENT,
75          n("reefdb.property.comment"),
76          n("reefdb.survey.measurement.grouped.comment.tip"),
77          String.class);
78  
79      /**
80       * Constructor.
81       *
82       * @param columnModel Le modele pour les colonnes
83       */
84      public SurveyMeasurementsGroupedTableModel(final TableColumnModelExt columnModel, boolean createNewRow) {
85          super(columnModel, createNewRow);
86      }
87  
88      /**
89       * {@inheritDoc}
90       */
91      @Override
92      public SurveyMeasurementsGroupedRowModel createNewRow() {
93          return new SurveyMeasurementsGroupedRowModel(false);
94      }
95  
96      /**
97       * {@inheritDoc}
98       */
99      @Override
100     public ReefDbColumnIdentifier<SurveyMeasurementsGroupedRowModel> getFirstColumnEditing() {
101         return TAXON_GROUP;
102     }
103 
104     @Override
105     public ReefDbColumnIdentifier<SurveyMeasurementsGroupedRowModel> getPmfmInsertPosition() {
106         return INPUT_TAXON_NAME;
107     }
108 
109     /**
110      * {@inheritDoc}
111      */
112     @Override
113     public AbstractMeasurementsGroupedTableUIModel getTableUIModel() {
114         return (AbstractMeasurementsGroupedTableUIModel) super.getTableUIModel();
115     }
116 
117     /**
118      * {@inheritDoc}
119      */
120     @Override
121     public String getStateContext() {
122         if (getTableUIModel().getSurvey() != null && getTableUIModel().getSurvey().getProgram() != null) {
123 
124             return SurveyMeasurementsGroupedTableUIModel.PROPERTY_SURVEY + '_'
125                 + SurveyDTO.PROPERTY_INDIVIDUAL_PMFMS + '_'
126                 + getTableUIModel().getSurvey().getProgram().getCode();
127         }
128 
129         return super.getStateContext();
130     }
131 
132 }