1 package fr.ifremer.reefdb.ui.swing.content.manage.program.programs;
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.ui.swing.util.table.AbstractReefDbTableModel;
28 import fr.ifremer.reefdb.ui.swing.util.table.ReefDbColumnIdentifier;
29 import org.jdesktop.swingx.table.TableColumnModelExt;
30
31 import java.util.Date;
32
33 import static org.nuiton.i18n.I18n.n;
34
35
36
37
38 public class ProgramsTableModel extends AbstractReefDbTableModel<ProgramsTableRowModel> {
39
40
41
42
43 public static final ReefDbColumnIdentifier<ProgramsTableRowModel> NAME = ReefDbColumnIdentifier.newId(
44 ProgramsTableRowModel.PROPERTY_NAME,
45 n("reefdb.property.name"),
46 n("reefdb.program.program.name.tip"),
47 String.class,
48 true);
49
50
51
52
53 public static final ReefDbColumnIdentifier<ProgramsTableRowModel> DESCRIPTION = ReefDbColumnIdentifier.newId(
54 ProgramsTableRowModel.PROPERTY_DESCRIPTION,
55 n("reefdb.property.description"),
56 n("reefdb.program.program.description.tip"),
57 String.class,
58 true);
59
60
61
62
63 public static final ReefDbColumnIdentifier<ProgramsTableRowModel> CODE = ReefDbColumnIdentifier.newId(
64 ProgramsTableRowModel.PROPERTY_CODE,
65 n("reefdb.property.code"),
66 n("reefdb.program.program.code.tip"),
67 String.class,
68 true);
69
70 public static final ReefDbColumnIdentifier<ProgramsTableRowModel> DEPARTMENT_HERMETIC = ReefDbColumnIdentifier.newId(
71 ProgramsTableRowModel.PROPERTY_DEPARTMENT_HERMETIC,
72 n("reefdb.property.departmentHermetic"),
73 n("reefdb.program.program.departmentHermetic.tip"),
74 Boolean.class,
75 true);
76
77
78
79
80 public static final ReefDbColumnIdentifier<ProgramsTableRowModel> STATUS = ReefDbColumnIdentifier.newId(
81 ProgramsTableRowModel.PROPERTY_STATUS,
82 n("reefdb.property.referential.local"),
83 n("reefdb.program.program.local.tip"),
84 Boolean.class);
85
86 public static final ReefDbColumnIdentifier<ProgramsTableRowModel> COMMENT = ReefDbColumnIdentifier.newId(
87 ProgramsTableRowModel.PROPERTY_COMMENT,
88 n("reefdb.property.comment"),
89 n("reefdb.property.comment"),
90 String.class,
91 false);
92
93 public static final ReefDbColumnIdentifier<ProgramsTableRowModel> CREATION_DATE = ReefDbColumnIdentifier.newReadOnlyId(
94 ProgramsTableRowModel.PROPERTY_CREATION_DATE,
95 n("reefdb.property.date.creation"),
96 n("reefdb.property.date.creation"),
97 Date.class);
98
99 public static final ReefDbColumnIdentifier<ProgramsTableRowModel> UPDATE_DATE = ReefDbColumnIdentifier.newReadOnlyId(
100 ProgramsTableRowModel.PROPERTY_UPDATE_DATE,
101 n("reefdb.property.date.modification"),
102 n("reefdb.property.date.modification"),
103 Date.class);
104
105
106
107
108
109
110
111
112 public ProgramsTableModel(final TableColumnModelExt columnModel) {
113 super(columnModel, true, false);
114 }
115
116
117 @Override
118 public ProgramsTableRowModel createNewRow() {
119 return new ProgramsTableRowModel();
120 }
121
122
123 @Override
124 public ReefDbColumnIdentifier<ProgramsTableRowModel> getFirstColumnEditing() {
125 return NAME;
126 }
127
128 @Override
129 public boolean isCellEditable(int rowIndex, int columnIndex, org.nuiton.jaxx.application.swing.table.ColumnIdentifier<ProgramsTableRowModel> propertyName) {
130
131 if (DEPARTMENT_HERMETIC == propertyName) {
132 ProgramsTableRowModel rowModel = getEntry(rowIndex);
133 return rowModel.isEditable() && !rowModel.isLocal();
134 } else if (DESCRIPTION == propertyName) {
135 return true;
136 }
137
138 return super.isCellEditable(rowIndex, columnIndex, propertyName);
139 }
140 }