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