1 package fr.ifremer.tutti.ui.swing.content.genericformat;
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.tutti.persistence.entities.data.Program;
28 import fr.ifremer.tutti.persistence.model.ProgramDataModel;
29 import fr.ifremer.tutti.service.genericformat.GenericFormatExportConfiguration;
30 import fr.ifremer.tutti.ui.swing.content.genericformat.tree.ProgramSelectTreeNode;
31 import org.jdesktop.beans.AbstractSerializableBean;
32
33
34
35
36
37
38
39 public class GenericFormatExportUIModel extends AbstractSerializableBean {
40
41 private static final long serialVersionUID = 1L;
42
43 public static final String PROPERTY_PROGRAM = "program";
44
45 public static final String PROPERTY_EXPORT_ATTACHMENTS = "exportAttachments";
46
47 public static final String PROPERTY_EXPORT_SPECIES = "exportSpecies";
48
49 public static final String PROPERTY_EXPORT_BENTHOS = "exportBenthos";
50
51 public static final String PROPERTY_EXPORT_MARINE_LITTER = "exportMarineLitter";
52
53 public static final String PROPERTY_EXPORT_ACCIDENTAL_CATCH = "exportAccidentalCatch";
54
55 public static final String PROPERTY_EXPORT_INDIVIDUAL_OBSERVATION = "exportIndividualObservation";
56
57 public static final String PROPERTY_DATA_SELECTED= "dataSelected";
58
59 public static final String PROPERTY_CAN_EXPORT = "canExport";
60
61 private Program program;
62
63 private boolean exportSpecies = true;
64
65 private boolean exportBenthos = true;
66
67 private boolean exportMarineLitter = true;
68
69 private boolean exportAccidentalCatch = true;
70
71 private boolean exportIndividualObservation = true;
72
73 private boolean exportAttachments = true;
74
75 private boolean canExport;
76
77 private boolean dataSelected;
78
79 private ProgramSelectTreeNode rootNode;
80
81 public GenericFormatExportConfiguration toExportConfiguration() {
82
83 GenericFormatExportConfiguration configuration = new GenericFormatExportConfiguration();
84
85 configuration.setExportSpecies(exportSpecies);
86 configuration.setExportBenthos(exportBenthos);
87 configuration.setExportMarineLitter(exportMarineLitter);
88 configuration.setExportAccidentalCatch(exportAccidentalCatch);
89 configuration.setExportIndividualObservation(exportIndividualObservation);
90 configuration.setExportAttachments(exportAttachments);
91
92 ProgramDataModel selectedDataModel = rootNode.getSelectedDataModel();
93 configuration.setDataToExport(selectedDataModel);
94
95 return configuration;
96
97 }
98
99 public Program getProgram() {
100 return program;
101 }
102
103 public void setProgram(Program program) {
104 Object oldValue = getProgram();
105 this.program = program;
106 firePropertyChange(PROPERTY_PROGRAM, oldValue, program);
107 }
108
109 public boolean isExportSpecies() {
110 return exportSpecies;
111 }
112
113 public void setExportSpecies(boolean exportSpecies) {
114 this.exportSpecies = exportSpecies;
115 firePropertyChange(PROPERTY_EXPORT_SPECIES, null, exportSpecies);
116 }
117
118 public boolean isExportBenthos() {
119 return exportBenthos;
120 }
121
122 public void setExportBenthos(boolean exportBenthos) {
123 this.exportBenthos = exportBenthos;
124 firePropertyChange(PROPERTY_EXPORT_BENTHOS, null, exportBenthos);
125 }
126
127 public boolean isExportMarineLitter() {
128 return exportMarineLitter;
129 }
130
131 public void setExportMarineLitter(boolean exportMarineLitter) {
132 this.exportMarineLitter = exportMarineLitter;
133 firePropertyChange(PROPERTY_EXPORT_MARINE_LITTER, null, exportMarineLitter);
134 }
135
136 public boolean isExportAccidentalCatch() {
137 return exportAccidentalCatch;
138 }
139
140 public void setExportAccidentalCatch(boolean exportAccidentalCatch) {
141 this.exportAccidentalCatch = exportAccidentalCatch;
142 firePropertyChange(PROPERTY_EXPORT_ACCIDENTAL_CATCH, null, exportAccidentalCatch);
143 }
144
145 public boolean isExportIndividualObservation() {
146 return exportIndividualObservation;
147 }
148
149 public void setExportIndividualObservation(boolean exportIndividualObservation) {
150 this.exportIndividualObservation = exportIndividualObservation;
151 firePropertyChange(PROPERTY_EXPORT_INDIVIDUAL_OBSERVATION, null, exportIndividualObservation);
152 }
153
154 public boolean isExportAttachments() {
155 return exportAttachments;
156 }
157
158 public void setExportAttachments(boolean exportAttachments) {
159 this.exportAttachments = exportAttachments;
160 firePropertyChange(PROPERTY_EXPORT_ATTACHMENTS, null, exportAttachments);
161 }
162
163 public boolean isCanExport() {
164 return canExport;
165 }
166
167 public void setCanExport(boolean canExport) {
168 this.canExport = canExport;
169 firePropertyChange(PROPERTY_CAN_EXPORT, null, canExport);
170 }
171
172 public boolean isDataSelected() {
173 return dataSelected;
174 }
175
176 public void setDataSelected(boolean dataSelected) {
177 this.dataSelected = dataSelected;
178 firePropertyChange(PROPERTY_DATA_SELECTED, null, dataSelected);
179 }
180
181 public boolean computeIsCanExport() {
182
183 return getProgram() != null && isDataSelected();
184 }
185
186 public void setRootNode(ProgramSelectTreeNode rootNode) {
187 this.rootNode = rootNode;
188 }
189
190 public ProgramSelectTreeNode getRootNode() {
191 return rootNode;
192 }
193 }