1
2
3
4
5
6
7 package fr.ifremer.dali.ui.swing.content.manage.referential.department.table;
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 import fr.ifremer.dali.dto.referential.DepartmentDTO;
33 import fr.ifremer.dali.ui.swing.util.table.AbstractDaliTableModel;
34 import fr.ifremer.dali.ui.swing.util.table.DaliColumnIdentifier;
35 import fr.ifremer.quadrige3.ui.core.dto.referential.StatusDTO;
36 import fr.ifremer.quadrige3.ui.swing.table.SwingTableColumnModel;
37
38 import java.util.Date;
39
40 import static org.nuiton.i18n.I18n.n;
41
42
43
44
45
46
47 public class DepartmentTableModel extends AbstractDaliTableModel<DepartmentRowModel> {
48
49 private final boolean readOnly;
50
51
52
53
54
55
56 public DepartmentTableModel(final SwingTableColumnModel columnModel, boolean createNewRowAllowed) {
57 super(columnModel, createNewRowAllowed, false);
58 readOnly = !createNewRowAllowed;
59 }
60
61
62 @Override
63 public DepartmentRowModel createNewRow() {
64 return new DepartmentRowModel(readOnly);
65 }
66
67
68 public static final DaliColumnIdentifier<DepartmentRowModel> CODE = DaliColumnIdentifier.newId(
69 DepartmentRowModel.PROPERTY_CODE,
70 n("dali.property.code"),
71 n("dali.property.code"),
72 String.class,
73 true);
74
75
76 public static final DaliColumnIdentifier<DepartmentRowModel> NAME = DaliColumnIdentifier.newId(
77 DepartmentRowModel.PROPERTY_NAME,
78 n("dali.property.name"),
79 n("dali.property.name"),
80 String.class,
81 true);
82
83
84 public static final DaliColumnIdentifier<DepartmentRowModel> DESCRIPTION = DaliColumnIdentifier.newId(
85 DepartmentRowModel.PROPERTY_DESCRIPTION,
86 n("dali.property.description"),
87 n("dali.property.description"),
88 String.class);
89
90
91 public static final DaliColumnIdentifier<DepartmentRowModel> PARENT_DEPARTMENT = DaliColumnIdentifier.newId(
92 DepartmentRowModel.PROPERTY_PARENT_DEPARTMENT,
93 n("dali.property.department.parent"),
94 n("dali.property.department.parent"),
95 DepartmentDTO.class);
96
97
98 public static final DaliColumnIdentifier<DepartmentRowModel> EMAIL = DaliColumnIdentifier.newId(
99 DepartmentRowModel.PROPERTY_EMAIL,
100 n("dali.property.email"),
101 n("dali.property.email"),
102 String.class);
103
104
105 public static final DaliColumnIdentifier<DepartmentRowModel> PHONE = DaliColumnIdentifier.newId(
106 DepartmentRowModel.PROPERTY_PHONE,
107 n("dali.property.phone"),
108 n("dali.property.phone"),
109 String.class);
110
111
112 public static final DaliColumnIdentifier<DepartmentRowModel> ADDRESS = DaliColumnIdentifier.newId(
113 DepartmentRowModel.PROPERTY_ADDRESS,
114 n("dali.property.address"),
115 n("dali.property.address"),
116 String.class);
117
118
119 public static final DaliColumnIdentifier<DepartmentRowModel> STATUS = DaliColumnIdentifier.newId(
120 DepartmentRowModel.PROPERTY_STATUS,
121 n("dali.property.status"),
122 n("dali.property.status"),
123 StatusDTO.class,
124 true);
125
126 public static final DaliColumnIdentifier<DepartmentRowModel> COMMENT = DaliColumnIdentifier.newId(
127 DepartmentRowModel.PROPERTY_COMMENT,
128 n("dali.property.comment"),
129 n("dali.property.comment"),
130 String.class,
131 false);
132
133 public static final DaliColumnIdentifier<DepartmentRowModel> CREATION_DATE = DaliColumnIdentifier.newReadOnlyId(
134 DepartmentRowModel.PROPERTY_CREATION_DATE,
135 n("dali.property.date.creation"),
136 n("dali.property.date.creation"),
137 Date.class);
138
139 public static final DaliColumnIdentifier<DepartmentRowModel> UPDATE_DATE = DaliColumnIdentifier.newReadOnlyId(
140 DepartmentRowModel.PROPERTY_UPDATE_DATE,
141 n("dali.property.date.modification"),
142 n("dali.property.date.modification"),
143 Date.class);
144
145
146
147
148 @Override
149 public DaliColumnIdentifier<DepartmentRowModel> getFirstColumnEditing() {
150 return CODE;
151 }
152 }