View Javadoc
1   package fr.ifremer.reefdb.ui.swing.content.manage.referential.pmfm.matrix.table;
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.quadrige3.ui.core.dto.referential.StatusDTO;
28  import fr.ifremer.reefdb.dto.referential.pmfm.FractionDTO;
29  import fr.ifremer.reefdb.ui.swing.util.table.AbstractReefDbTableModel;
30  import fr.ifremer.reefdb.ui.swing.util.table.ReefDbColumnIdentifier;
31  import org.jdesktop.swingx.table.TableColumnModelExt;
32  
33  import java.util.Date;
34  
35  import static org.nuiton.i18n.I18n.n;
36  
37  /**
38   * Model.
39   */
40  public class MatricesTableModel extends AbstractReefDbTableModel<MatricesTableRowModel> {
41  
42      /** Constant <code>NAME</code> */
43      public static final ReefDbColumnIdentifier<MatricesTableRowModel> NAME = ReefDbColumnIdentifier.newId(
44              MatricesTableRowModel.PROPERTY_NAME,
45              n("reefdb.property.name"),
46              n("reefdb.property.name"),
47              String.class,
48              true);
49  
50      /** Constant <code>DESCRIPTION</code> */
51      public static final ReefDbColumnIdentifier<MatricesTableRowModel> DESCRIPTION = ReefDbColumnIdentifier.newId(
52              MatricesTableRowModel.PROPERTY_DESCRIPTION,
53              n("reefdb.property.description"),
54              n("reefdb.property.description"),
55              String.class);
56  
57      /** Constant <code>STATUS</code> */
58      public static final ReefDbColumnIdentifier<MatricesTableRowModel> STATUS = ReefDbColumnIdentifier.newId(
59              MatricesTableRowModel.PROPERTY_STATUS,
60              n("reefdb.property.status"),
61              n("reefdb.property.status"),
62              StatusDTO.class,
63              true);
64  
65      /** Constant <code>ASSOCIATED_FRACTIONS</code> */
66      public static final ReefDbColumnIdentifier<MatricesTableRowModel> ASSOCIATED_FRACTIONS = ReefDbColumnIdentifier.newId(
67              MatricesTableRowModel.PROPERTY_FRACTIONS,
68              n("reefdb.property.pmfm.matrix.associatedFractions"),
69              n("reefdb.property.pmfm.matrix.associatedFractions"),
70              FractionDTO.class,
71              DecoratorService.COLLECTION_SIZE,
72              true);
73  
74  
75      public static final ReefDbColumnIdentifier<MatricesTableRowModel> COMMENT = ReefDbColumnIdentifier.newId(
76          MatricesTableRowModel.PROPERTY_COMMENT,
77          n("reefdb.property.comment"),
78          n("reefdb.property.comment"),
79          String.class,
80          false);
81  
82      public static final ReefDbColumnIdentifier<MatricesTableRowModel> CREATION_DATE = ReefDbColumnIdentifier.newReadOnlyId(
83          MatricesTableRowModel.PROPERTY_CREATION_DATE,
84          n("reefdb.property.date.creation"),
85          n("reefdb.property.date.creation"),
86          Date.class);
87  
88      public static final ReefDbColumnIdentifier<MatricesTableRowModel> UPDATE_DATE = ReefDbColumnIdentifier.newReadOnlyId(
89          MatricesTableRowModel.PROPERTY_UPDATE_DATE,
90          n("reefdb.property.date.modification"),
91          n("reefdb.property.date.modification"),
92          Date.class);
93  
94      /**
95       * <p>Constructor for MatricesTableModel.</p>
96       *
97       * @param columnModel a {@link org.jdesktop.swingx.table.TableColumnModelExt} object.
98       * @param createNewRowAllowed a boolean.
99       */
100     public MatricesTableModel(final TableColumnModelExt columnModel, boolean createNewRowAllowed) {
101         super(columnModel, createNewRowAllowed, false);
102     }
103 
104     /** {@inheritDoc} */
105     @Override
106     public MatricesTableRowModel createNewRow() {
107         return new MatricesTableRowModel();
108     }
109 
110     /** {@inheritDoc} */
111     @Override
112     public ReefDbColumnIdentifier<MatricesTableRowModel> getFirstColumnEditing() {
113         return NAME;
114     }
115 }