1 package fr.ifremer.reefdb.ui.swing.content.observation.photo;
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 import fr.ifremer.reefdb.decorator.DecoratorService;
27 import fr.ifremer.reefdb.dto.data.sampling.SamplingOperationDTO;
28 import fr.ifremer.reefdb.dto.referential.PhotoTypeDTO;
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
39
40 public class PhotosTableModel extends AbstractReefDbTableModel<PhotosTableRowModel> {
41
42
43
44
45 public static final ReefDbColumnIdentifier<PhotosTableRowModel> NAME = ReefDbColumnIdentifier.newId(
46 PhotosTableRowModel.PROPERTY_NAME,
47 n("reefdb.property.name"),
48 n("reefdb.photo.name.tip"),
49 String.class,
50 true);
51
52
53
54
55 public static final ReefDbColumnIdentifier<PhotosTableRowModel> TYPE = ReefDbColumnIdentifier.newId(
56 PhotosTableRowModel.PROPERTY_PHOTO_TYPE,
57 n("reefdb.photo.type"),
58 n("reefdb.photo.type.tip"),
59 PhotoTypeDTO.class);
60
61
62
63
64 public static final ReefDbColumnIdentifier<PhotosTableRowModel> CAPTION = ReefDbColumnIdentifier.newId(
65 PhotosTableRowModel.PROPERTY_CAPTION,
66 n("reefdb.photo.caption"),
67 n("reefdb.photo.caption.tip"),
68 String.class);
69
70
71
72
73 public static final ReefDbColumnIdentifier<PhotosTableRowModel> DATE = ReefDbColumnIdentifier.newId(
74 PhotosTableRowModel.PROPERTY_DATE,
75 n("reefdb.property.date"),
76 n("reefdb.photo.date.tip"),
77 Date.class,
78 true);
79
80
81
82
83 public static final ReefDbColumnIdentifier<PhotosTableRowModel> SAMPLING_OPERATION = ReefDbColumnIdentifier.newId(
84 PhotosTableRowModel.PROPERTY_SAMPLING_OPERATION,
85 n("reefdb.property.samplingOperation"),
86 n("reefdb.photo.samplingOperation.tip"),
87 SamplingOperationDTO.class,
88 DecoratorService.CONCAT);
89
90
91
92
93 public static final ReefDbColumnIdentifier<PhotosTableRowModel> DIRECTION = ReefDbColumnIdentifier.newId(
94 PhotosTableRowModel.PROPERTY_DIRECTION,
95 n("reefdb.photo.direction"),
96 n("reefdb.photo.direction.tip"),
97 String.class);
98
99
100
101
102 public static final ReefDbColumnIdentifier<PhotosTableRowModel> PATH = ReefDbColumnIdentifier.newId(
103 PhotosTableRowModel.PROPERTY_PATH,
104 n("reefdb.photo.path"),
105 n("reefdb.photo.path.tip"),
106 String.class);
107
108 private boolean readOnly;
109
110
111
112
113
114
115 public PhotosTableModel(final TableColumnModelExt columnModel) {
116 super(columnModel, false, false);
117 this.readOnly = false;
118 }
119
120
121
122
123
124
125 public void setReadOnly(boolean readOnly) {
126 this.readOnly = readOnly;
127 }
128
129
130 @Override
131 public PhotosTableRowModel createNewRow() {
132 return new PhotosTableRowModel(readOnly);
133 }
134
135
136 @Override
137 public ReefDbColumnIdentifier<PhotosTableRowModel> getFirstColumnEditing() {
138 return NAME;
139 }
140 }