1 package fr.ifremer.reefdb.ui.swing.content.manage.program.locations;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 import fr.ifremer.reefdb.dto.referential.DepartmentDTO;
28 import fr.ifremer.reefdb.ui.swing.util.table.AbstractReefDbTableModel;
29 import fr.ifremer.reefdb.ui.swing.util.table.ReefDbColumnIdentifier;
30 import org.jdesktop.swingx.table.TableColumnModelExt;
31
32 import java.time.LocalDate;
33
34 import static org.nuiton.i18n.I18n.n;
35
36
37
38
39 public class LocationsTableModel extends AbstractReefDbTableModel<LocationsTableRowModel> {
40
41
42
43
44 public static final ReefDbColumnIdentifier<LocationsTableRowModel> CODE = ReefDbColumnIdentifier.newId(
45 LocationsTableRowModel.PROPERTY_ID,
46 n("reefdb.property.code"),
47 n("reefdb.program.location.code.tip"),
48 Integer.class);
49
50
51
52
53 public static final ReefDbColumnIdentifier<LocationsTableRowModel> LABEL = ReefDbColumnIdentifier.newId(
54 LocationsTableRowModel.PROPERTY_LABEL,
55 n("reefdb.property.label"),
56 n("reefdb.program.location.label.tip"),
57 String.class);
58
59
60
61
62 public static final ReefDbColumnIdentifier<LocationsTableRowModel> NAME = ReefDbColumnIdentifier.newId(
63 LocationsTableRowModel.PROPERTY_NAME,
64 n("reefdb.program.location.name.short"),
65 n("reefdb.program.location.name.tip"),
66 String.class);
67
68
69
70
71 public static final ReefDbColumnIdentifier<LocationsTableRowModel> START_DATE = ReefDbColumnIdentifier.newId(
72 LocationsTableRowModel.PROPERTY_START_DATE,
73 n("reefdb.program.location.startDate.short"),
74 n("reefdb.program.location.startDate.tip"),
75 LocalDate.class);
76
77
78
79
80 public static final ReefDbColumnIdentifier<LocationsTableRowModel> END_DATE = ReefDbColumnIdentifier.newId(
81 LocationsTableRowModel.PROPERTY_END_DATE,
82 n("reefdb.program.location.endDate.short"),
83 n("reefdb.program.location.endDate.tip"),
84 LocalDate.class);
85
86
87
88
89 public static final ReefDbColumnIdentifier<LocationsTableRowModel> PRELEVEUR = ReefDbColumnIdentifier.newId(
90 LocationsTableRowModel.PROPERTY_DEPARTMENT,
91 n("reefdb.program.location.department"),
92 n("reefdb.program.location.department.tip"),
93 DepartmentDTO.class);
94
95
96
97
98
99
100 public LocationsTableModel(final TableColumnModelExt columnModel) {
101 super(columnModel, false, false);
102 }
103
104
105 @Override
106 public LocationsTableRowModel createNewRow() {
107 return new LocationsTableRowModel();
108 }
109
110
111 @Override
112 public ReefDbColumnIdentifier<LocationsTableRowModel> getFirstColumnEditing() {
113 return CODE;
114 }
115
116 @Override
117 public boolean isCellEditable(int rowIndex, int columnIndex, org.nuiton.jaxx.application.swing.table.ColumnIdentifier<LocationsTableRowModel> propertyName) {
118
119 if (propertyName == PRELEVEUR) {
120 LocationsTableRowModel rowModel = getEntry(rowIndex);
121 return rowModel.getStartDate() != null && rowModel.getEndDate() != null;
122 }
123
124 return super.isCellEditable(rowIndex, columnIndex, propertyName);
125 }
126 }