View Javadoc
1   package fr.ifremer.dali.ui.swing.content.manage.program.programs;
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  
27  import fr.ifremer.dali.ui.swing.util.table.AbstractDaliTableModel;
28  import fr.ifremer.dali.ui.swing.util.table.DaliColumnIdentifier;
29  import fr.ifremer.quadrige3.ui.swing.table.SwingTableColumnModel;
30  import org.nuiton.jaxx.application.swing.table.ColumnIdentifier;
31  
32  import java.util.Date;
33  
34  import static org.nuiton.i18n.I18n.n;
35  
36  /**
37   * Le modele pour le tableau des programmes.
38   */
39  public class ProgramsTableModel extends AbstractDaliTableModel<ProgramsTableRowModel> {
40  
41  	/**
42  	 * Identifiant pour la colonne libelle.
43  	 */
44      public static final DaliColumnIdentifier<ProgramsTableRowModel> NAME = DaliColumnIdentifier.newId(
45      		ProgramsTableRowModel.PROPERTY_NAME,
46              n("dali.property.name"),
47              n("dali.program.program.name.tip"),
48              String.class,
49              true);
50  
51      /**
52       * Identifiant pour la colonne description.
53       */
54      public static final DaliColumnIdentifier<ProgramsTableRowModel> DESCRIPTION = DaliColumnIdentifier.newId(
55      		ProgramsTableRowModel.PROPERTY_DESCRIPTION,
56              n("dali.property.description"),
57              n("dali.program.program.description.tip"),
58              String.class,
59              true);
60  
61      /**
62       * Identifiant pour la colonne code.
63       */
64      public static final DaliColumnIdentifier<ProgramsTableRowModel> CODE = DaliColumnIdentifier.newReadOnlyId(
65      		ProgramsTableRowModel.PROPERTY_CODE,
66              n("dali.property.code"),
67              n("dali.program.program.code.tip"),
68              String.class);
69  
70      public static final DaliColumnIdentifier<ProgramsTableRowModel> DEPARTMENT_HERMETIC = DaliColumnIdentifier.newId(
71  			ProgramsTableRowModel.PROPERTY_DEPARTMENT_HERMETIC,
72  			n("dali.property.departmentHermetic"),
73  			n("dali.program.program.departmentHermetic.tip"),
74  			Boolean.class,
75  			true);
76  
77  	public static final DaliColumnIdentifier<ProgramsTableRowModel> COMMENT = DaliColumnIdentifier.newId(
78  			ProgramsTableRowModel.PROPERTY_COMMENT,
79  			n("dali.property.comment"),
80  			n("dali.property.comment"),
81  			String.class,
82  			false);
83  
84  	public static final DaliColumnIdentifier<ProgramsTableRowModel> CREATION_DATE = DaliColumnIdentifier.newReadOnlyId(
85  			ProgramsTableRowModel.PROPERTY_CREATION_DATE,
86  			n("dali.property.date.creation"),
87  			n("dali.property.date.creation"),
88  			Date.class);
89  
90      public static final DaliColumnIdentifier<ProgramsTableRowModel> UPDATE_DATE = DaliColumnIdentifier.newReadOnlyId(
91  			ProgramsTableRowModel.PROPERTY_UPDATE_DATE,
92  			n("dali.property.date.modification"),
93  			n("dali.property.date.modification"),
94  			Date.class);
95  
96  
97  
98  	/**
99  	 * Constructor.
100 	 *
101 	 * @param columnModel Le modele pour les colonnes
102 	 */
103 	public ProgramsTableModel(final SwingTableColumnModel columnModel) {
104 		super(columnModel, false, false);
105     }
106 
107 	/** {@inheritDoc} */
108 	@Override
109 	public ProgramsTableRowModel createNewRow() {
110 		return new ProgramsTableRowModel();
111 	}
112 
113 	/** {@inheritDoc} */
114 	@Override
115 	public DaliColumnIdentifier<ProgramsTableRowModel> getFirstColumnEditing() {
116 		return NAME;
117 	}
118 
119 	@Override
120 	public boolean isCellEditable(int rowIndex, int columnIndex, ColumnIdentifier<ProgramsTableRowModel> propertyName) {
121 
122 		if (ProgramsTableRowModel.PROPERTY_DESCRIPTION.equals(propertyName.getPropertyName())) {
123 			return true;
124 		}
125 
126 		return super.isCellEditable(rowIndex, columnIndex, propertyName);
127 	}
128 }