View Javadoc
1   package fr.ifremer.tutti.ui.swing.content.operation.catches.accidental;
2   
3   /*
4    * #%L
5    * Tutti :: UI
6    * %%
7    * Copyright (C) 2012 - 2014 Ifremer
8    * %%
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU General Public License as
11   * published by the Free Software Foundation, either version 3 of the 
12   * License, or (at your option) any later version.
13   * 
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * 
19   * You should have received a copy of the GNU General Public 
20   * License along with this program.  If not, see
21   * <http://www.gnu.org/licenses/gpl-3.0.html>.
22   * #L%
23   */
24  
25  import fr.ifremer.tutti.type.WeightUnit;
26  import org.jdesktop.swingx.table.TableColumnModelExt;
27  import org.nuiton.jaxx.application.swing.table.AbstractApplicationTableModel;
28  import org.nuiton.jaxx.application.swing.table.ColumnIdentifier;
29  
30  import static org.nuiton.i18n.I18n.n;
31  
32  /**
33   * @author Tony Chemit - chemit@codelutin.com
34   * @since 0.2
35   */
36  public class AccidentalBatchTableModel extends AbstractApplicationTableModel<AccidentalBatchRowModel> {
37  
38      private static final long serialVersionUID = 1L;
39  
40      public static final ColumnIdentifier<AccidentalBatchRowModel> ID = ColumnIdentifier.newId(
41              AccidentalBatchRowModel.PROPERTY_ID,
42              n("tutti.editAccidentalBatch.table.header.id"),
43              n("tutti.editAccidentalBatch.table.header.id.tip"));
44  
45      public static final ColumnIdentifier<AccidentalBatchRowModel> SPECIES = ColumnIdentifier.newId(
46              AccidentalBatchRowModel.PROPERTY_SPECIES,
47              n("tutti.editAccidentalBatch.table.header.species"),
48              n("tutti.editAccidentalBatch.table.header.species.tip"));
49  
50      public static final ColumnIdentifier<AccidentalBatchRowModel> GENDER = ColumnIdentifier.newId(
51              AccidentalBatchRowModel.PROPERTY_GENDER,
52              n("tutti.editAccidentalBatch.table.header.gender"),
53              n("tutti.editAccidentalBatch.table.header.gender.tip"));
54  
55      public static final ColumnIdentifier<AccidentalBatchRowModel> WEIGHT = ColumnIdentifier.newId(
56              AccidentalBatchRowModel.PROPERTY_WEIGHT,
57              n("tutti.editAccidentalBatch.table.header.weight"),
58              n("tutti.editAccidentalBatch.table.header.weight.tip"));
59  
60      public static final ColumnIdentifier<AccidentalBatchRowModel> SIZE = ColumnIdentifier.newId(
61              AccidentalBatchRowModel.PROPERTY_SIZE,
62              n("tutti.editAccidentalBatch.table.header.size"),
63              n("tutti.editAccidentalBatch.table.header.size.tip"));
64  
65      public static final ColumnIdentifier<AccidentalBatchRowModel> LENGTH_STEP_CARACTERISTIC = ColumnIdentifier.newId(
66              AccidentalBatchRowModel.PROPERTY_LENGTH_STEP_CARACTERISTIC,
67              n("tutti.editAccidentalBatch.table.header.lengthStepCaracteristic"),
68              n("tutti.editAccidentalBatch.table.header.lengthStepCaracteristic.tip"));
69  
70      public static final ColumnIdentifier<AccidentalBatchRowModel> DEAD_OR_ALIVE = ColumnIdentifier.newId(
71              AccidentalBatchRowModel.PROPERTY_DEAD_OR_ALIVE,
72              n("tutti.editAccidentalBatch.table.header.deadOrAlive"),
73              n("tutti.editAccidentalBatch.table.header.deadOrAlive.tip"));
74  
75  //    public static final ColumnIdentifier<AccidentalBatchRowModel> OTHER_CARACTERISTICS = ColumnIdentifier.newId(
76  //            IndividualObservationBatchRowModel.PROPERTY_CARACTERISTICS,
77  //            n("tutti.editAccidentalBatch.table.header.otherCaracteristics"),
78  //            n("tutti.editAccidentalBatch.table.header.otherCaracteristics.tip"));
79  
80      public static final ColumnIdentifier<AccidentalBatchRowModel> COMMENT = ColumnIdentifier.newId(
81              AccidentalBatchRowModel.PROPERTY_COMMENT,
82              n("tutti.editAccidentalBatch.table.header.comment"),
83              n("tutti.editAccidentalBatch.table.header.comment.tip"));
84  
85      public static final ColumnIdentifier<AccidentalBatchRowModel> ATTACHMENT = ColumnIdentifier.newReadOnlyId(
86              AccidentalBatchRowModel.PROPERTY_ATTACHMENT,
87              n("tutti.editAccidentalBatch.table.header.file"),
88              n("tutti.editAccidentalBatch.table.header.file.tip"));
89  
90      /**
91       * Weight unit.
92       *
93       * @since 2.5
94       */
95      protected final WeightUnit weightUnit;
96  
97      public AccidentalBatchTableModel(WeightUnit weightUnit,
98                                       TableColumnModelExt columnModel) {
99          super(columnModel, false, false);
100         this.weightUnit = weightUnit;
101         setNoneEditableCols(ID);
102     }
103 
104     @Override
105     public AccidentalBatchRowModel createNewRow() {
106         AccidentalBatchRowModel result = new AccidentalBatchRowModel(weightUnit);
107 
108         // by default empty row is not valid
109         result.setValid(false);
110         return result;
111     }
112 }