View Javadoc
1   package fr.ifremer.dali.ui.swing.content.observation.survey.measurement.ungrouped;
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.data.survey.SurveyDTO;
27  import fr.ifremer.dali.dto.referential.DepartmentDTO;
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.swing.table.SwingTableColumnModel;
31  
32  import static org.nuiton.i18n.I18n.n;
33  
34  /**
35   * Le modele pour le tableau du haut (Psfm) pour l onglet des mesures de l'observation.
36   */
37  public class SurveyMeasurementsUngroupedTableModel extends AbstractDaliTableModel<SurveyMeasurementsUngroupedRowModel> {
38  
39      /**
40       * Identifiant pour la colonne analyst.
41       */
42      public static final DaliColumnIdentifier<SurveyMeasurementsUngroupedRowModel> ANALYST = DaliColumnIdentifier.newId(
43              SurveyMeasurementsUngroupedRowModel.PROPERTY_ANALYST,
44              n("dali.property.analyst"),
45              n("dali.survey.measurement.grouped.analyst.tip"),
46              DepartmentDTO.class);
47  
48      private boolean readOnly;
49  
50      /**
51       * Constructor.
52       *
53       * @param columnModel Le modele pour les colonnes
54       */
55      public SurveyMeasurementsUngroupedTableModel(final SwingTableColumnModel columnModel) {
56          super(columnModel, false, false);
57          this.readOnly = false;
58      }
59  
60      /**
61       * <p>Setter for the field <code>readOnly</code>.</p>
62       *
63       * @param readOnly a boolean.
64       */
65      public void setReadOnly(boolean readOnly) {
66          this.readOnly = readOnly;
67      }
68  
69      /**
70       * {@inheritDoc}
71       */
72      @Override
73      public SurveyMeasurementsUngroupedRowModel createNewRow() {
74          return new SurveyMeasurementsUngroupedRowModel(readOnly);
75      }
76  
77      /**
78       * {@inheritDoc}
79       */
80      @Override
81      public DaliColumnIdentifier<SurveyMeasurementsUngroupedRowModel> getFirstColumnEditing() {
82          return null;
83      }
84  
85      /**
86       * {@inheritDoc}
87       */
88      @Override
89      public SurveyMeasurementsUngroupedTableUIModel getTableUIModel() {
90          return (SurveyMeasurementsUngroupedTableUIModel) super.getTableUIModel();
91      }
92  
93      /**
94       * {@inheritDoc}
95       */
96      @Override
97      public String getStateContext() {
98          if (getTableUIModel().getSurvey() != null && getTableUIModel().getSurvey().getProgram() != null) {
99  
100             return SurveyMeasurementsUngroupedTableUIModel.PROPERTY_SURVEY + '_'
101                     + SurveyDTO.PROPERTY_PMFMS + '_'
102                     + getTableUIModel().getSurvey().getProgram().getCode();
103         }
104 
105         return super.getStateContext();
106     }
107 
108 }