Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
26 changed files:
- client-core/src/main/java/fr/ird/observe/client/util/UIHelper.java
- client-datasource-actions/src/main/java/fr/ird/observe/client/datasource/actions/report/actions/ChooseFileReport.java
- client-datasource-editor-api/src/main/java/fr/ird/observe/client/datasource/editor/wizard/tabs/actions/ConfigDataUIChooseDumpFileAction.java
- client-datasource-editor-api/src/main/java/fr/ird/observe/client/datasource/editor/wizard/tabs/actions/ConfigReferentialUIChooseDumpFileAction.java
- client-datasource-editor-api/src/main/java/fr/ird/observe/client/datasource/editor/wizard/tabs/actions/ConfigUIChooseDumpFileAction.java
- client-datasource-editor-common/src/main/java/fr/ird/observe/client/datasource/editor/content/data/trip/map/actions/ExportPng.java
- client-datasource-editor-ll/pom.xml
- client-datasource-editor-ll/src/main/i18n/getters/java.getter
- client-datasource-editor-ll/src/main/i18n/getters/jaxx.getter
- client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/ObserveLLKeyStrokes.java
- client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/observation/SensorUsedUI.jaxx
- client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/observation/SensorUsedUI.jcss
- client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/observation/SensorUsedUIHandler.java
- client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/observation/TdrUI.jaxx
- client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/observation/TdrUI.jcss
- client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/observation/TdrUIHandler.java
- + client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/observation/actions/SensorUsedUIActionSupport.java
- + client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/observation/actions/SensorUsedUIDeleteData.java
- + client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/observation/actions/SensorUsedUIExportData.java
- + client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/observation/actions/SensorUsedUIImportData.java
- + client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/observation/actions/TdrUIActionSupport.java
- + client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/observation/actions/TdrUIDeleteData.java
- + client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/observation/actions/TdrUIExportData.java
- + client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/observation/actions/TdrUIImportData.java
- validation/src/main/resources/fr/ird/observe/dto/data/ll/observation/SetDto-create-error-validation.xml
- validation/src/main/resources/fr/ird/observe/dto/data/ll/observation/SetDto-update-error-validation.xml
Changes:
| ... | ... | @@ -173,16 +173,16 @@ public class UIHelper extends SwingUtil { |
| 173 | 173 |
/**
|
| 174 | 174 |
* Choisir un fichier via un sélecteur graphique de fichiers.
|
| 175 | 175 |
*
|
| 176 |
- * @param parent le component swing appelant le controle
|
|
| 177 |
- * @param title le titre du dialogue de sélection
|
|
| 178 |
- * @param buttonLabel le label du boutton d'acceptation
|
|
| 179 |
- * @param incoming le fichier de base à utilier
|
|
| 180 |
- * @param filters les filtres + descriptions sur le sélecteur de
|
|
| 181 |
- * fichiers
|
|
| 176 |
+ * @param parent le component swing appelant le controle
|
|
| 177 |
+ * @param title le titre du dialogue de sélection
|
|
| 178 |
+ * @param buttonLabel le label du boutton d'acceptation
|
|
| 179 |
+ * @param incoming le fichier de base à utilier
|
|
| 180 |
+ * @param mainExtension l'extension principale (à rajouter sur le nom du fichier si besoin)
|
|
| 181 |
+ * @param filters les filtres + descriptions sur le sélecteur de fichiers
|
|
| 182 | 182 |
* @return le fichier choisi ou le fichier incoming si l'opération a été
|
| 183 | 183 |
* annulée
|
| 184 | 184 |
*/
|
| 185 |
- public static File chooseFile(Component parent, String title, String buttonLabel, File incoming, String... filters) {
|
|
| 185 |
+ public static File chooseFile(Component parent, String title, String buttonLabel, File incoming, String mainExtension, String... filters) {
|
|
| 186 | 186 |
|
| 187 | 187 |
JaxxFileChooser.ToLoadFile toLoadFile = JaxxFileChooser.forLoadingFile()
|
| 188 | 188 |
.setParent(parent)
|
| ... | ... | @@ -199,7 +199,7 @@ public class UIHelper extends SwingUtil { |
| 199 | 199 |
if (log.isDebugEnabled()) {
|
| 200 | 200 |
log.debug(title + " : " + file);
|
| 201 | 201 |
}
|
| 202 |
- return file == null ? incoming : file;
|
|
| 202 |
+ return file == null ? incoming : ensureFileExtension(file, mainExtension);
|
|
| 203 | 203 |
}
|
| 204 | 204 |
|
| 205 | 205 |
/**
|
| ... | ... | @@ -229,6 +229,13 @@ public class UIHelper extends SwingUtil { |
| 229 | 229 |
return file;
|
| 230 | 230 |
}
|
| 231 | 231 |
|
| 232 |
+ public static File ensureFileExtension(File file, String extension) {
|
|
| 233 |
+ if (extension != null && !file.getName().toLowerCase().endsWith(extension)) {
|
|
| 234 |
+ file = file.toPath().getParent().resolve(file.getName() + extension).toFile();
|
|
| 235 |
+ }
|
|
| 236 |
+ return file;
|
|
| 237 |
+ }
|
|
| 238 |
+ |
|
| 232 | 239 |
private static File getParentDirectoryIfExist(File incoming) {
|
| 233 | 240 |
if (incoming != null) {
|
| 234 | 241 |
File basedir;
|
| ... | ... | @@ -26,6 +26,7 @@ import fr.ird.observe.client.datasource.actions.report.ReportConfigUI; |
| 26 | 26 |
import fr.ird.observe.client.datasource.actions.report.ReportModel;
|
| 27 | 27 |
import fr.ird.observe.client.util.ObserveKeyStrokesSupport;
|
| 28 | 28 |
import fr.ird.observe.client.util.UIHelper;
|
| 29 |
+import fr.ird.observe.dto.ObserveUtil;
|
|
| 29 | 30 |
import org.nuiton.jaxx.runtime.swing.action.JComponentActionSupport;
|
| 30 | 31 |
|
| 31 | 32 |
import java.awt.event.ActionEvent;
|
| ... | ... | @@ -42,13 +43,13 @@ public class ChooseFileReport extends JComponentActionSupport<ReportConfigUI> { |
| 42 | 43 |
@Override
|
| 43 | 44 |
protected void doActionPerformed(ActionEvent e, ReportConfigUI ui) {
|
| 44 | 45 |
ReportModel model = ui.getModel().getReportModel();
|
| 45 |
- File f = UIHelper.chooseFile(
|
|
| 46 |
- ui,
|
|
| 47 |
- t("observe.title.choose.reportFile"),
|
|
| 48 |
- t("observe.action.choose.reportFile"),
|
|
| 49 |
- model.getReportFile(),
|
|
| 50 |
- "^.+\\.properties$",
|
|
| 51 |
- t("observe.action.choose.reportFile.description"));
|
|
| 46 |
+ File f = UIHelper.chooseFile(ui,
|
|
| 47 |
+ t("observe.title.choose.reportFile"),
|
|
| 48 |
+ t("observe.action.choose.reportFile"),
|
|
| 49 |
+ model.getReportFile(),
|
|
| 50 |
+ ObserveUtil.PROPERTIES_EXTENSION,
|
|
| 51 |
+ ObserveUtil.PROPERTIES_EXTENSION_PATTERN,
|
|
| 52 |
+ t("observe.action.choose.reportFile.description"));
|
|
| 52 | 53 |
if (f != null) {
|
| 53 | 54 |
model.setReportFile(f);
|
| 54 | 55 |
}
|
| ... | ... | @@ -41,11 +41,12 @@ public class ConfigDataUIChooseDumpFileAction extends StorageTabUIActionSupport< |
| 41 | 41 |
@Override
|
| 42 | 42 |
protected void doActionPerformed(ActionEvent e, ConfigDataUI ui) {
|
| 43 | 43 |
File f = UIHelper.chooseFile(ui,
|
| 44 |
- t("observe.title.choose.db.dump"),
|
|
| 45 |
- t("observe.action.choose.db.dump"),
|
|
| 46 |
- ui.getModel().getDumpFile(),
|
|
| 47 |
- ObserveUtil.SQL_GZ_EXTENSION_PATTERN,
|
|
| 48 |
- t("observe.action.choose.db.dump.description"));
|
|
| 44 |
+ t("observe.title.choose.db.dump"),
|
|
| 45 |
+ t("observe.action.choose.db.dump"),
|
|
| 46 |
+ ui.getModel().getDumpFile(),
|
|
| 47 |
+ ObserveUtil.SQL_GZ_EXTENSION,
|
|
| 48 |
+ ObserveUtil.SQL_GZ_EXTENSION_PATTERN,
|
|
| 49 |
+ t("observe.action.choose.db.dump.description"));
|
|
| 49 | 50 |
if (f != null) {
|
| 50 | 51 |
ui.getHandler().setDumpFile(f.getAbsolutePath());
|
| 51 | 52 |
}
|
| ... | ... | @@ -41,11 +41,12 @@ public class ConfigReferentialUIChooseDumpFileAction extends StorageTabUIActionS |
| 41 | 41 |
@Override
|
| 42 | 42 |
protected void doActionPerformed(ActionEvent e, ConfigReferentialUI ui) {
|
| 43 | 43 |
File f = UIHelper.chooseFile(ui,
|
| 44 |
- t("observe.title.choose.db.dump"),
|
|
| 45 |
- t("observe.action.choose.db.dump"),
|
|
| 46 |
- ui.getModel().getDumpFile(),
|
|
| 47 |
- ObserveUtil.SQL_GZ_EXTENSION_PATTERN,
|
|
| 48 |
- t("observe.action.choose.db.dump.description"));
|
|
| 44 |
+ t("observe.title.choose.db.dump"),
|
|
| 45 |
+ t("observe.action.choose.db.dump"),
|
|
| 46 |
+ ui.getModel().getDumpFile(),
|
|
| 47 |
+ ObserveUtil.SQL_GZ_EXTENSION,
|
|
| 48 |
+ ObserveUtil.SQL_GZ_EXTENSION_PATTERN,
|
|
| 49 |
+ t("observe.action.choose.db.dump.description"));
|
|
| 49 | 50 |
if (f != null) {
|
| 50 | 51 |
ui.getHandler().setDumpFile(f.getAbsolutePath());
|
| 51 | 52 |
}
|
| ... | ... | @@ -41,11 +41,12 @@ public class ConfigUIChooseDumpFileAction extends StorageTabUIActionSupport<Conf |
| 41 | 41 |
@Override
|
| 42 | 42 |
protected void doActionPerformed(ActionEvent event, ConfigUI ui) {
|
| 43 | 43 |
File f = UIHelper.chooseFile(ui,
|
| 44 |
- t("observe.title.choose.db.dump"),
|
|
| 45 |
- t("observe.action.choose.db.dump"),
|
|
| 46 |
- ui.getModel().getDumpFile(),
|
|
| 47 |
- ObserveUtil.SQL_GZ_EXTENSION_PATTERN,
|
|
| 48 |
- t("observe.action.choose.db.dump.description"));
|
|
| 44 |
+ t("observe.title.choose.db.dump"),
|
|
| 45 |
+ t("observe.action.choose.db.dump"),
|
|
| 46 |
+ ui.getModel().getDumpFile(),
|
|
| 47 |
+ ObserveUtil.SQL_GZ_EXTENSION,
|
|
| 48 |
+ ObserveUtil.SQL_GZ_EXTENSION_PATTERN,
|
|
| 49 |
+ t("observe.action.choose.db.dump.description"));
|
|
| 49 | 50 |
if (f != null) {
|
| 50 | 51 |
ui.getHandler().setDumpFile(f.getAbsolutePath());
|
| 51 | 52 |
}
|
| ... | ... | @@ -26,6 +26,7 @@ import fr.ird.observe.client.datasource.editor.content.data.trip.map.TripMapUI; |
| 26 | 26 |
import fr.ird.observe.client.util.ObserveKeyStrokesSupport;
|
| 27 | 27 |
import fr.ird.observe.client.util.ObserveSwingTechnicalException;
|
| 28 | 28 |
import fr.ird.observe.client.util.UIHelper;
|
| 29 |
+import fr.ird.observe.dto.ObserveUtil;
|
|
| 29 | 30 |
import org.apache.logging.log4j.LogManager;
|
| 30 | 31 |
import org.apache.logging.log4j.Logger;
|
| 31 | 32 |
|
| ... | ... | @@ -57,13 +58,13 @@ public class ExportPng extends TripMapUIActionSupport { |
| 57 | 58 |
@Override
|
| 58 | 59 |
protected void doActionPerformed(ActionEvent event, TripMapUI ui) {
|
| 59 | 60 |
|
| 60 |
- File file = UIHelper.chooseFile(
|
|
| 61 |
- ui,
|
|
| 62 |
- t("observe.content.map.export.chooseFile.title"),
|
|
| 63 |
- t("observe.content.map.export.chooseFile.ok"),
|
|
| 64 |
- null,
|
|
| 65 |
- "^.+\\.png|.+\\.PNG$",
|
|
| 66 |
- t("observe.content.map.export.chooseFile.png"));
|
|
| 61 |
+ File file = UIHelper.chooseFile(ui,
|
|
| 62 |
+ t("observe.content.map.export.chooseFile.title"),
|
|
| 63 |
+ t("observe.content.map.export.chooseFile.ok"),
|
|
| 64 |
+ null,
|
|
| 65 |
+ ObserveUtil.PNG_EXTENSION,
|
|
| 66 |
+ ObserveUtil.PNG_EXTENSION_PATTERN,
|
|
| 67 |
+ t("observe.content.map.export.chooseFile.png"));
|
|
| 67 | 68 |
|
| 68 | 69 |
if (file != null && UIHelper.confirmOverwriteFileIfExist(ui, file)) {
|
| 69 | 70 |
|
| ... | ... | @@ -137,10 +137,6 @@ |
| 137 | 137 |
<groupId>io.ultreia.java4all.jaxx</groupId>
|
| 138 | 138 |
<artifactId>jaxx-widgets-datetime</artifactId>
|
| 139 | 139 |
</dependency>
|
| 140 |
- <dependency>
|
|
| 141 |
- <groupId>io.ultreia.java4all.jaxx</groupId>
|
|
| 142 |
- <artifactId>jaxx-widgets-status</artifactId>
|
|
| 143 |
- </dependency>
|
|
| 144 | 140 |
<dependency>
|
| 145 | 141 |
<groupId>io.ultreia.java4all.jaxx</groupId>
|
| 146 | 142 |
<artifactId>jaxx-widgets-select</artifactId>
|
| ... | ... | @@ -225,7 +225,12 @@ observe.data.ll.observation.SensorUsed.action.importData |
| 225 | 225 |
observe.data.ll.observation.SensorUsed.choose.title.exportData
|
| 226 | 226 |
observe.data.ll.observation.SensorUsed.choose.title.importData
|
| 227 | 227 |
observe.data.ll.observation.SensorUsed.delete.data.message
|
| 228 |
-observe.data.ll.observation.SensorUsed.message.data.exported
|
|
| 228 |
+observe.data.ll.observation.SensorUsed.deleteData
|
|
| 229 |
+observe.data.ll.observation.SensorUsed.deleteData.tip
|
|
| 230 |
+observe.data.ll.observation.SensorUsed.exportData
|
|
| 231 |
+observe.data.ll.observation.SensorUsed.exportData.tip
|
|
| 232 |
+observe.data.ll.observation.SensorUsed.importData
|
|
| 233 |
+observe.data.ll.observation.SensorUsed.importData.tip
|
|
| 229 | 234 |
observe.data.ll.observation.SensorUsed.replace.data.message
|
| 230 | 235 |
observe.data.ll.observation.SensorUsed.table.data
|
| 231 | 236 |
observe.data.ll.observation.SensorUsed.table.data.tip
|
| ... | ... | @@ -289,7 +294,12 @@ observe.data.ll.observation.Tdr.action.exportData |
| 289 | 294 |
observe.data.ll.observation.Tdr.action.importData
|
| 290 | 295 |
observe.data.ll.observation.Tdr.choose.title.exportData
|
| 291 | 296 |
observe.data.ll.observation.Tdr.choose.title.importData
|
| 292 |
-observe.data.ll.observation.Tdr.delete.data.message
|
|
| 297 |
+observe.data.ll.observation.Tdr.deleteData
|
|
| 298 |
+observe.data.ll.observation.Tdr.deleteData.tip
|
|
| 299 |
+observe.data.ll.observation.Tdr.exportData
|
|
| 300 |
+observe.data.ll.observation.Tdr.exportData.tip
|
|
| 301 |
+observe.data.ll.observation.Tdr.importData
|
|
| 302 |
+observe.data.ll.observation.Tdr.importData.tip
|
|
| 293 | 303 |
observe.data.ll.observation.Tdr.replace.data.message
|
| 294 | 304 |
observe.data.ll.observation.Tdr.table.data
|
| 295 | 305 |
observe.data.ll.observation.Tdr.table.data.tip
|
| ... | ... | @@ -319,12 +319,6 @@ observe.data.ll.observation.SensorUsed.action.create.tip |
| 319 | 319 |
observe.data.ll.observation.SensorUsed.data
|
| 320 | 320 |
observe.data.ll.observation.SensorUsed.dataLocation
|
| 321 | 321 |
observe.data.ll.observation.SensorUsed.dataLocation.tip
|
| 322 |
-observe.data.ll.observation.SensorUsed.deleteData
|
|
| 323 |
-observe.data.ll.observation.SensorUsed.deleteData.tip
|
|
| 324 |
-observe.data.ll.observation.SensorUsed.exportData
|
|
| 325 |
-observe.data.ll.observation.SensorUsed.exportData.tip
|
|
| 326 |
-observe.data.ll.observation.SensorUsed.importData
|
|
| 327 |
-observe.data.ll.observation.SensorUsed.importData.tip
|
|
| 328 | 322 |
observe.data.ll.observation.SensorUsed.sensorBrand
|
| 329 | 323 |
observe.data.ll.observation.SensorUsed.sensorDataFormat
|
| 330 | 324 |
observe.data.ll.observation.SensorUsed.sensorSerialNo
|
| ... | ... | @@ -414,22 +408,16 @@ observe.data.ll.observation.Tdr.caracteristicsTab |
| 414 | 408 |
observe.data.ll.observation.Tdr.data
|
| 415 | 409 |
observe.data.ll.observation.Tdr.dataLocation
|
| 416 | 410 |
observe.data.ll.observation.Tdr.dataLocation.tip
|
| 417 |
-observe.data.ll.observation.Tdr.deleteData
|
|
| 418 |
-observe.data.ll.observation.Tdr.deleteData.tip
|
|
| 419 | 411 |
observe.data.ll.observation.Tdr.deployementEnd
|
| 420 | 412 |
observe.data.ll.observation.Tdr.deployementStart
|
| 421 | 413 |
observe.data.ll.observation.Tdr.enableTimestamp
|
| 422 | 414 |
observe.data.ll.observation.Tdr.enableTimestamp.tip
|
| 423 |
-observe.data.ll.observation.Tdr.exportData
|
|
| 424 |
-observe.data.ll.observation.Tdr.exportData.tip
|
|
| 425 | 415 |
observe.data.ll.observation.Tdr.fishingEnd
|
| 426 | 416 |
observe.data.ll.observation.Tdr.fishingEndDepth
|
| 427 | 417 |
observe.data.ll.observation.Tdr.fishingStart
|
| 428 | 418 |
observe.data.ll.observation.Tdr.fishingStartDepth
|
| 429 | 419 |
observe.data.ll.observation.Tdr.floatline1Length
|
| 430 | 420 |
observe.data.ll.observation.Tdr.floatline2Length
|
| 431 |
-observe.data.ll.observation.Tdr.importData
|
|
| 432 |
-observe.data.ll.observation.Tdr.importData.tip
|
|
| 433 | 421 |
observe.data.ll.observation.Tdr.itemHorizontalPosition
|
| 434 | 422 |
observe.data.ll.observation.Tdr.itemVerticalPosition
|
| 435 | 423 |
observe.data.ll.observation.Tdr.keyDataTab
|
| ... | ... | @@ -41,4 +41,7 @@ public class ObserveLLKeyStrokes extends ObserveKeyStrokesSupport { |
| 41 | 41 |
public static final KeyStroke KEY_STROKE_ADD_SET_LONGLINE = KeyStroke.getKeyStroke("ctrl pressed L");
|
| 42 | 42 |
public static final KeyStroke KEY_STROKE_ADD_SAMPLE_LONGLINE = KeyStroke.getKeyStroke("ctrl pressed M");
|
| 43 | 43 |
public static final KeyStroke KEY_STROKE_GENERATE_ID = KeyStroke.getKeyStroke("ctrl pressed G");
|
| 44 |
+ public static final KeyStroke KEY_STROKE_IMPORT_DATA = KeyStroke.getKeyStroke("ctrl pressed I");
|
|
| 45 |
+ public static final KeyStroke KEY_STROKE_DELETE_DATA = KeyStroke.getKeyStroke("shift ctrl pressed D");
|
|
| 46 |
+ public static final KeyStroke KEY_STROKE_EXPORT_DATA = KeyStroke.getKeyStroke("ctrl pressed E");
|
|
| 44 | 47 |
}
|
| ... | ... | @@ -126,9 +126,9 @@ |
| 126 | 126 |
</cell>
|
| 127 | 127 |
<cell weightx='1' anchor='east'>
|
| 128 | 128 |
<JPanel layout='{new GridLayout()}'>
|
| 129 |
- <JButton id="importDataButton" onActionPerformed="getHandler().importData()"/>
|
|
| 130 |
- <JButton id="exportDataButton" onActionPerformed="getHandler().exportData()"/>
|
|
| 131 |
- <JButton id="deleteDataButton" onActionPerformed="getHandler().deleteData()"/>
|
|
| 129 |
+ <JButton id="importData"/>
|
|
| 130 |
+ <JButton id="exportData"/>
|
|
| 131 |
+ <JButton id="deleteData"/>
|
|
| 132 | 132 |
</JPanel>
|
| 133 | 133 |
</cell>
|
| 134 | 134 |
</row>
|
| ... | ... | @@ -24,22 +24,10 @@ |
| 24 | 24 |
toolTipText:"observe.data.ll.observation.SensorUsed.dataLocation.tip";
|
| 25 | 25 |
}
|
| 26 | 26 |
|
| 27 |
-#importDataButton {
|
|
| 28 |
- actionIcon:data-import;
|
|
| 29 |
- text:"observe.data.ll.observation.SensorUsed.importData";
|
|
| 30 |
- toolTipText:"observe.data.ll.observation.SensorUsed.importData.tip";
|
|
| 31 |
-}
|
|
| 32 |
- |
|
| 33 |
-#exportDataButton {
|
|
| 34 |
- actionIcon:data-export;
|
|
| 35 |
- text:"observe.data.ll.observation.SensorUsed.exportData";
|
|
| 36 |
- toolTipText:"observe.data.ll.observation.SensorUsed.exportData.tip";
|
|
| 27 |
+#exportData {
|
|
| 37 | 28 |
enabled:{tableEditBean.isHasData()};
|
| 38 | 29 |
}
|
| 39 | 30 |
|
| 40 |
-#deleteDataButton {
|
|
| 41 |
- actionIcon:delete;
|
|
| 42 |
- text:"observe.data.ll.observation.SensorUsed.deleteData";
|
|
| 43 |
- toolTipText:"observe.data.ll.observation.SensorUsed.deleteData.tip";
|
|
| 31 |
+#deleteData {
|
|
| 44 | 32 |
enabled:{tableEditBean.isHasData()};
|
| 45 | 33 |
}
|
| ... | ... | @@ -22,13 +22,9 @@ package fr.ird.observe.client.datasource.editor.content.data.ll.observation; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
-import fr.ird.observe.client.ClientUIContextApplicationComponent;
|
|
| 26 | 25 |
import fr.ird.observe.client.datasource.editor.content.data.table.ContentTableUIHandler;
|
| 27 | 26 |
import fr.ird.observe.client.datasource.editor.content.data.table.ContentTableUILayoutFocusTraversalPolicy;
|
| 28 |
-import fr.ird.observe.client.main.ObserveMainUI;
|
|
| 29 |
-import fr.ird.observe.client.util.ObserveSwingTechnicalException;
|
|
| 30 | 27 |
import fr.ird.observe.client.util.UIHelper;
|
| 31 |
-import fr.ird.observe.dto.data.DataFileDto;
|
|
| 32 | 28 |
import fr.ird.observe.dto.data.ll.observation.ActivitySensorUsedDto;
|
| 33 | 29 |
import fr.ird.observe.dto.data.ll.observation.SensorUsedDto;
|
| 34 | 30 |
import fr.ird.observe.dto.form.Form;
|
| ... | ... | @@ -39,19 +35,13 @@ import fr.ird.observe.dto.result.SaveResultDto; |
| 39 | 35 |
import org.apache.logging.log4j.LogManager;
|
| 40 | 36 |
import org.apache.logging.log4j.Logger;
|
| 41 | 37 |
import org.nuiton.jaxx.runtime.spi.UIHandler;
|
| 42 |
-import org.nuiton.jaxx.widgets.file.JaxxFileChooser;
|
|
| 43 | 38 |
|
| 44 |
-import javax.swing.JOptionPane;
|
|
| 45 | 39 |
import javax.swing.JTable;
|
| 46 | 40 |
import javax.swing.table.DefaultTableCellRenderer;
|
| 47 | 41 |
import java.awt.Component;
|
| 48 | 42 |
import java.awt.Container;
|
| 49 |
-import java.io.File;
|
|
| 50 |
-import java.io.IOException;
|
|
| 51 |
-import java.nio.file.Files;
|
|
| 52 | 43 |
|
| 53 | 44 |
import static io.ultreia.java4all.i18n.I18n.n;
|
| 54 |
-import static io.ultreia.java4all.i18n.I18n.t;
|
|
| 55 | 45 |
|
| 56 | 46 |
/**
|
| 57 | 47 |
* Created on 8/31/14.
|
| ... | ... | @@ -138,78 +128,4 @@ public class SensorUsedUIHandler extends ContentTableUIHandler<ActivitySensorUse |
| 138 | 128 |
saveResult.toDto(bean);
|
| 139 | 129 |
}
|
| 140 | 130 |
|
| 141 |
- public void importData() {
|
|
| 142 |
- SensorUsedDto tableEditBean = getModel().getTableEditBean();
|
|
| 143 |
- if (tableEditBean.isHasData()) {
|
|
| 144 |
- DataFileDto dataFile = tableEditBean.getData();
|
|
| 145 |
- if (dataFile == null) {
|
|
| 146 |
- dataFile = getLlObservationActivitySensorUsedService().getDataFile(tableEditBean.getId());
|
|
| 147 |
- }
|
|
| 148 |
- int response = UIHelper.askUser(ui,
|
|
| 149 |
- t("observe.title.confirmReplace"),
|
|
| 150 |
- t("observe.data.ll.observation.SensorUsed.replace.data.message", dataFile.getName()),
|
|
| 151 |
- JOptionPane.WARNING_MESSAGE,
|
|
| 152 |
- new Object[]{t("observe.choice.confirm.replace"),
|
|
| 153 |
- t("observe.choice.cancel")},
|
|
| 154 |
- 1);
|
|
| 155 |
- boolean doReplace = response == 0;
|
|
| 156 |
- if (!doReplace) {
|
|
| 157 |
- return;
|
|
| 158 |
- }
|
|
| 159 |
- }
|
|
| 160 |
- File file = UIHelper.chooseFile(ui,
|
|
| 161 |
- t("observe.data.ll.observation.SensorUsed.choose.title.importData"),
|
|
| 162 |
- t("observe.data.ll.observation.SensorUsed.action.importData"),
|
|
| 163 |
- null);
|
|
| 164 |
- if (file != null) {
|
|
| 165 |
- log.info(prefix + "Set data from file: " + file);
|
|
| 166 |
- DataFileDto dataFileDto = UIHelper.fileToDataFileDto(file);
|
|
| 167 |
- tableEditBean.setData(dataFileDto);
|
|
| 168 |
- tableEditBean.setHasData(true);
|
|
| 169 |
- }
|
|
| 170 |
- }
|
|
| 171 |
- |
|
| 172 |
- public void deleteData() {
|
|
| 173 |
- int response = UIHelper.askUser(ui,
|
|
| 174 |
- t("observe.title.delete"),
|
|
| 175 |
- t("observe.data.ll.observation.SensorUsed.delete.data.message"),
|
|
| 176 |
- JOptionPane.WARNING_MESSAGE,
|
|
| 177 |
- new Object[]{t("observe.choice.confirm.delete"),
|
|
| 178 |
- t("observe.choice.cancel")},
|
|
| 179 |
- 1);
|
|
| 180 |
- boolean doDelete = response == 0;
|
|
| 181 |
- if (doDelete) {
|
|
| 182 |
- SensorUsedDto tableEditBean = getModel().getTableEditBean();
|
|
| 183 |
- log.info(prefix + "Delete sensorUsed data " + tableEditBean.getData());
|
|
| 184 |
- tableEditBean.setData(null);
|
|
| 185 |
- tableEditBean.setHasData(false);
|
|
| 186 |
- }
|
|
| 187 |
- }
|
|
| 188 |
- |
|
| 189 |
- public void exportData() {
|
|
| 190 |
- SensorUsedDto tableEditBean = getModel().getTableEditBean();
|
|
| 191 |
- DataFileDto dataFile = tableEditBean.getData();
|
|
| 192 |
- if (dataFile == null) {
|
|
| 193 |
- dataFile = getLlObservationActivitySensorUsedService().getDataFile(tableEditBean.getId());
|
|
| 194 |
- }
|
|
| 195 |
- File file = JaxxFileChooser
|
|
| 196 |
- .forSaving()
|
|
| 197 |
- .setParent(ui)
|
|
| 198 |
- .setTitle(t("observe.data.ll.observation.SensorUsed.choose.title.exportData"))
|
|
| 199 |
- .setApprovalText(t("observe.data.ll.observation.SensorUsed.action.exportData"))
|
|
| 200 |
- .setFilename(dataFile.getName())
|
|
| 201 |
- .setUseAcceptAllFileFilter(true)
|
|
| 202 |
- .choose();
|
|
| 203 |
- |
|
| 204 |
- if (file != null && UIHelper.confirmOverwriteFileIfExist(ui, file)) {
|
|
| 205 |
- log.info(prefix + "save sensorUsed data to " + file);
|
|
| 206 |
- try {
|
|
| 207 |
- Files.write(file.toPath(), dataFile.getContent());
|
|
| 208 |
- ObserveMainUI mainUI = ClientUIContextApplicationComponent.value().getMainUI();
|
|
| 209 |
- mainUI.getStatus().setStatus(t("observe.data.ll.observation.SensorUsed.message.data.exported", file));
|
|
| 210 |
- } catch (IOException e) {
|
|
| 211 |
- throw new ObserveSwingTechnicalException("Could not save binary data to " + file, e);
|
|
| 212 |
- }
|
|
| 213 |
- }
|
|
| 214 |
- }
|
|
| 215 | 131 |
}
|
| ... | ... | @@ -133,9 +133,9 @@ |
| 133 | 133 |
</cell>
|
| 134 | 134 |
<cell weightx='1' anchor='east'>
|
| 135 | 135 |
<JPanel layout='{new GridLayout()}'>
|
| 136 |
- <JButton id="importDataButton" onActionPerformed="getHandler().importData()"/>
|
|
| 137 |
- <JButton id="exportDataButton" onActionPerformed="getHandler().exportData()"/>
|
|
| 138 |
- <JButton id="deleteDataButton" onActionPerformed="getHandler().deleteData()"/>
|
|
| 136 |
+ <JButton id="importData"/>
|
|
| 137 |
+ <JButton id="exportData"/>
|
|
| 138 |
+ <JButton id="deleteData"/>
|
|
| 139 | 139 |
</JPanel>
|
| 140 | 140 |
</cell>
|
| 141 | 141 |
</row>
|
| ... | ... | @@ -28,23 +28,11 @@ |
| 28 | 28 |
toolTipText:"observe.data.ll.observation.Tdr.dataLocation.tip";
|
| 29 | 29 |
}
|
| 30 | 30 |
|
| 31 |
-#importDataButton {
|
|
| 32 |
- actionIcon:data-import;
|
|
| 33 |
- text:"observe.data.ll.observation.Tdr.importData";
|
|
| 34 |
- toolTipText:"observe.data.ll.observation.Tdr.importData.tip";
|
|
| 35 |
-}
|
|
| 36 |
- |
|
| 37 |
-#exportDataButton {
|
|
| 38 |
- actionIcon:data-export;
|
|
| 39 |
- text:"observe.data.ll.observation.Tdr.exportData";
|
|
| 40 |
- toolTipText:"observe.data.ll.observation.Tdr.exportData.tip";
|
|
| 31 |
+#exportData {
|
|
| 41 | 32 |
enabled:{tableEditBean.isHasData()};
|
| 42 | 33 |
}
|
| 43 | 34 |
|
| 44 |
-#deleteDataButton {
|
|
| 45 |
- actionIcon:delete;
|
|
| 46 |
- text:"observe.data.ll.observation.Tdr.deleteData";
|
|
| 47 |
- toolTipText:"observe.data.ll.observation.Tdr.deleteData.tip";
|
|
| 35 |
+#deleteData {
|
|
| 48 | 36 |
enabled:{tableEditBean.isHasData()};
|
| 49 | 37 |
}
|
| 50 | 38 |
|
| ... | ... | @@ -22,16 +22,12 @@ package fr.ird.observe.client.datasource.editor.content.data.ll.observation; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
-import fr.ird.observe.client.ClientUIContextApplicationComponent;
|
|
| 26 | 25 |
import fr.ird.observe.client.datasource.editor.content.data.table.ContentTableModel;
|
| 27 | 26 |
import fr.ird.observe.client.datasource.editor.content.data.table.ContentTableUIHandler;
|
| 28 | 27 |
import fr.ird.observe.client.datasource.editor.content.data.table.ContentTableUILayoutFocusTraversalPolicy;
|
| 29 | 28 |
import fr.ird.observe.client.datasource.editor.content.data.table.ContentTableUIModel;
|
| 30 | 29 |
import fr.ird.observe.client.datasource.editor.content.spi.ContentUIReferenceCache;
|
| 31 |
-import fr.ird.observe.client.main.ObserveMainUI;
|
|
| 32 |
-import fr.ird.observe.client.util.ObserveSwingTechnicalException;
|
|
| 33 | 30 |
import fr.ird.observe.client.util.UIHelper;
|
| 34 |
-import fr.ird.observe.dto.data.DataFileDto;
|
|
| 35 | 31 |
import fr.ird.observe.dto.data.ll.observation.SetTdrDto;
|
| 36 | 32 |
import fr.ird.observe.dto.data.ll.observation.TdrDto;
|
| 37 | 33 |
import fr.ird.observe.dto.form.Form;
|
| ... | ... | @@ -40,20 +36,14 @@ import fr.ird.observe.dto.result.SaveResultDto; |
| 40 | 36 |
import org.apache.logging.log4j.LogManager;
|
| 41 | 37 |
import org.apache.logging.log4j.Logger;
|
| 42 | 38 |
import org.nuiton.jaxx.runtime.spi.UIHandler;
|
| 43 |
-import org.nuiton.jaxx.widgets.file.JaxxFileChooser;
|
|
| 44 | 39 |
|
| 45 | 40 |
import javax.swing.JComponent;
|
| 46 |
-import javax.swing.JOptionPane;
|
|
| 47 | 41 |
import javax.swing.JTable;
|
| 48 | 42 |
import javax.swing.table.DefaultTableCellRenderer;
|
| 49 |
-import java.io.File;
|
|
| 50 |
-import java.io.IOException;
|
|
| 51 |
-import java.nio.file.Files;
|
|
| 52 | 43 |
import java.util.Date;
|
| 53 | 44 |
import java.util.List;
|
| 54 | 45 |
|
| 55 | 46 |
import static io.ultreia.java4all.i18n.I18n.n;
|
| 56 |
-import static io.ultreia.java4all.i18n.I18n.t;
|
|
| 57 | 47 |
|
| 58 | 48 |
/**
|
| 59 | 49 |
* Created on 9/30/14.
|
| ... | ... | @@ -214,85 +204,6 @@ public class TdrUIHandler extends ContentTableUIHandler<SetTdrDto, TdrDto, TdrUI |
| 214 | 204 |
setTimestamp(bean, timeStamp);
|
| 215 | 205 |
}
|
| 216 | 206 |
|
| 217 |
- public void importData() {
|
|
| 218 |
- TdrDto tableEditBean = getModel().getTableEditBean();
|
|
| 219 |
- if (tableEditBean.isHasData()) {
|
|
| 220 |
- DataFileDto dataFile = tableEditBean.getData();
|
|
| 221 |
- if (dataFile == null) {
|
|
| 222 |
- dataFile = getLlObservationSetTdrService().getDataFile(tableEditBean.getId());
|
|
| 223 |
- }
|
|
| 224 |
- int response = UIHelper.askUser(ui,
|
|
| 225 |
- t("observe.title.confirmReplace"),
|
|
| 226 |
- t("observe.data.ll.observation.Tdr.replace.data.message", dataFile.getName()),
|
|
| 227 |
- JOptionPane.WARNING_MESSAGE,
|
|
| 228 |
- new Object[]{t("observe.choice.confirm.replace"),
|
|
| 229 |
- t("observe.choice.cancel")},
|
|
| 230 |
- 1);
|
|
| 231 |
- boolean doReplace = response == 0;
|
|
| 232 |
- if (!doReplace) {
|
|
| 233 |
- return;
|
|
| 234 |
- }
|
|
| 235 |
- }
|
|
| 236 |
- |
|
| 237 |
- File file = UIHelper.chooseFile(ui,
|
|
| 238 |
- t("observe.data.ll.observation.Tdr.choose.title.importData"),
|
|
| 239 |
- t("observe.data.ll.observation.Tdr.action.importData"),
|
|
| 240 |
- null);
|
|
| 241 |
- if (file != null) {
|
|
| 242 |
- log.info("Set data from file: " + file);
|
|
| 243 |
- DataFileDto dataFileDto = UIHelper.fileToDataFileDto(file);
|
|
| 244 |
- tableEditBean.setData(dataFileDto);
|
|
| 245 |
- tableEditBean.setHasData(true);
|
|
| 246 |
- }
|
|
| 247 |
- }
|
|
| 248 |
- |
|
| 249 |
- public void deleteData() {
|
|
| 250 |
- int response = UIHelper.askUser(ui,
|
|
| 251 |
- t("observe.title.delete"),
|
|
| 252 |
- t("observe.data.ll.observation.Tdr.delete.data.message"),
|
|
| 253 |
- JOptionPane.WARNING_MESSAGE,
|
|
| 254 |
- new Object[]{t("observe.choice.confirm.delete"),
|
|
| 255 |
- t("observe.choice.cancel")},
|
|
| 256 |
- 1);
|
|
| 257 |
- boolean doDelete = response == 0;
|
|
| 258 |
- if (doDelete) {
|
|
| 259 |
- TdrDto tableEditBean = getModel().getTableEditBean();
|
|
| 260 |
- log.info("Delete tdr data " + tableEditBean.getData());
|
|
| 261 |
- tableEditBean.setData(null);
|
|
| 262 |
- tableEditBean.setHasData(false);
|
|
| 263 |
- }
|
|
| 264 |
- }
|
|
| 265 |
- |
|
| 266 |
- public void exportData() {
|
|
| 267 |
- |
|
| 268 |
- TdrDto tableEditBean = getModel().getTableEditBean();
|
|
| 269 |
- DataFileDto dataFile = tableEditBean.getData();
|
|
| 270 |
- |
|
| 271 |
- if (dataFile == null) {
|
|
| 272 |
- dataFile = getLlObservationSetTdrService().getDataFile(tableEditBean.getId());
|
|
| 273 |
- }
|
|
| 274 |
- |
|
| 275 |
- File file = JaxxFileChooser
|
|
| 276 |
- .forSaving()
|
|
| 277 |
- .setParent(ui)
|
|
| 278 |
- .setTitle(t("observe.data.ll.observation.Tdr.choose.title.exportData"))
|
|
| 279 |
- .setApprovalText(t("observe.data.ll.observation.Tdr.action.exportData"))
|
|
| 280 |
- .setFilename(dataFile.getName())
|
|
| 281 |
- .setUseAcceptAllFileFilter(true)
|
|
| 282 |
- .choose();
|
|
| 283 |
- |
|
| 284 |
- if (file != null && UIHelper.confirmOverwriteFileIfExist(ui, file)) {
|
|
| 285 |
- log.info("save tdr data to " + file);
|
|
| 286 |
- try {
|
|
| 287 |
- Files.write(file.toPath(), dataFile.getContent());
|
|
| 288 |
- ObserveMainUI mainUI = ClientUIContextApplicationComponent.value().getMainUI();
|
|
| 289 |
- mainUI.getStatus().setStatus(t("observe.data.ll.observation.SensorUsed.message.data.exported", file));
|
|
| 290 |
- } catch (IOException e) {
|
|
| 291 |
- throw new ObserveSwingTechnicalException("Could not save binary data to " + file, e);
|
|
| 292 |
- }
|
|
| 293 |
- }
|
|
| 294 |
- }
|
|
| 295 |
- |
|
| 296 | 207 |
private void setTimestamp(TdrDto bean, Date timestamp) {
|
| 297 | 208 |
bean.setDeployementStart(timestamp);
|
| 298 | 209 |
bean.setDeployementEnd(timestamp);
|
| 1 |
+package fr.ird.observe.client.datasource.editor.content.data.ll.observation.actions;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client DataSource Editor LL
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2020 IRD, Code Lutin, Ultreia.io
|
|
| 8 |
+ * %%
|
|
| 9 |
+ * This program is free software: you can redistribute it and/or modify
|
|
| 10 |
+ * it under the terms of the GNU General Public License as
|
|
| 11 |
+ * published by the Free Software Foundation, either version 3 of the
|
|
| 12 |
+ * License, or (at your option) any later version.
|
|
| 13 |
+ *
|
|
| 14 |
+ * This program is distributed in the hope that it will be useful,
|
|
| 15 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 16 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 17 |
+ * GNU General Public License for more details.
|
|
| 18 |
+ *
|
|
| 19 |
+ * You should have received a copy of the GNU General Public
|
|
| 20 |
+ * License along with this program. If not, see
|
|
| 21 |
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 22 |
+ * #L%
|
|
| 23 |
+ */
|
|
| 24 |
+ |
|
| 25 |
+import fr.ird.observe.client.datasource.editor.content.actions.ContentUIActionSupport;
|
|
| 26 |
+import fr.ird.observe.client.datasource.editor.content.data.ll.observation.SensorUsedUI;
|
|
| 27 |
+ |
|
| 28 |
+import javax.swing.KeyStroke;
|
|
| 29 |
+ |
|
| 30 |
+/**
|
|
| 31 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 32 |
+ * @since 8
|
|
| 33 |
+ */
|
|
| 34 |
+public abstract class SensorUsedUIActionSupport extends ContentUIActionSupport<SensorUsedUI> {
|
|
| 35 |
+ |
|
| 36 |
+ protected SensorUsedUIActionSupport(String label, String shortDescription, String actionIcon, KeyStroke acceleratorKey) {
|
|
| 37 |
+ super(label, shortDescription, actionIcon, acceleratorKey);
|
|
| 38 |
+ }
|
|
| 39 |
+ |
|
| 40 |
+}
|
|
| 41 |
+ |
| 1 |
+package fr.ird.observe.client.datasource.editor.content.data.ll.observation.actions;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client DataSource Editor LL
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2020 IRD, Code Lutin, Ultreia.io
|
|
| 8 |
+ * %%
|
|
| 9 |
+ * This program is free software: you can redistribute it and/or modify
|
|
| 10 |
+ * it under the terms of the GNU General Public License as
|
|
| 11 |
+ * published by the Free Software Foundation, either version 3 of the
|
|
| 12 |
+ * License, or (at your option) any later version.
|
|
| 13 |
+ *
|
|
| 14 |
+ * This program is distributed in the hope that it will be useful,
|
|
| 15 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 16 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 17 |
+ * GNU General Public License for more details.
|
|
| 18 |
+ *
|
|
| 19 |
+ * You should have received a copy of the GNU General Public
|
|
| 20 |
+ * License along with this program. If not, see
|
|
| 21 |
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 22 |
+ * #L%
|
|
| 23 |
+ */
|
|
| 24 |
+ |
|
| 25 |
+import fr.ird.observe.client.datasource.editor.content.ObserveLLKeyStrokes;
|
|
| 26 |
+import fr.ird.observe.client.datasource.editor.content.data.ll.observation.SensorUsedUI;
|
|
| 27 |
+import fr.ird.observe.client.util.UIHelper;
|
|
| 28 |
+import fr.ird.observe.dto.data.ll.observation.SensorUsedDto;
|
|
| 29 |
+import org.apache.logging.log4j.LogManager;
|
|
| 30 |
+import org.apache.logging.log4j.Logger;
|
|
| 31 |
+ |
|
| 32 |
+import javax.swing.JOptionPane;
|
|
| 33 |
+import java.awt.event.ActionEvent;
|
|
| 34 |
+ |
|
| 35 |
+import static io.ultreia.java4all.i18n.I18n.n;
|
|
| 36 |
+import static io.ultreia.java4all.i18n.I18n.t;
|
|
| 37 |
+ |
|
| 38 |
+/**
|
|
| 39 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 40 |
+ * @since ?
|
|
| 41 |
+ */
|
|
| 42 |
+public class SensorUsedUIDeleteData extends SensorUsedUIActionSupport {
|
|
| 43 |
+ |
|
| 44 |
+ private static final Logger log = LogManager.getLogger(SensorUsedUIDeleteData.class);
|
|
| 45 |
+ |
|
| 46 |
+ public SensorUsedUIDeleteData() {
|
|
| 47 |
+ super(n("observe.data.ll.observation.SensorUsed.deleteData"), n("observe.data.ll.observation.SensorUsed.deleteData.tip"), "delete", ObserveLLKeyStrokes.KEY_STROKE_DELETE_DATA);
|
|
| 48 |
+ }
|
|
| 49 |
+ |
|
| 50 |
+ @Override
|
|
| 51 |
+ protected void doActionPerformed(ActionEvent e, SensorUsedUI ui) {
|
|
| 52 |
+ int response = UIHelper.askUser(ui,
|
|
| 53 |
+ t("observe.title.delete"),
|
|
| 54 |
+ t("observe.data.ll.observation.SensorUsed.delete.data.message"),
|
|
| 55 |
+ JOptionPane.WARNING_MESSAGE,
|
|
| 56 |
+ new Object[]{t("observe.choice.confirm.delete"),
|
|
| 57 |
+ t("observe.choice.cancel")},
|
|
| 58 |
+ 1);
|
|
| 59 |
+ boolean doDelete = response == 0;
|
|
| 60 |
+ if (doDelete) {
|
|
| 61 |
+ SensorUsedDto tableEditBean = ui.getModel().getTableEditBean();
|
|
| 62 |
+ log.info(String.format("%s Delete sensorUsed data %s", ui.getModel().getPrefix(), tableEditBean.getData()));
|
|
| 63 |
+ tableEditBean.setData(null);
|
|
| 64 |
+ tableEditBean.setHasData(false);
|
|
| 65 |
+ }
|
|
| 66 |
+ |
|
| 67 |
+ }
|
|
| 68 |
+}
|
| 1 |
+package fr.ird.observe.client.datasource.editor.content.data.ll.observation.actions;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client DataSource Editor LL
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2020 IRD, Code Lutin, Ultreia.io
|
|
| 8 |
+ * %%
|
|
| 9 |
+ * This program is free software: you can redistribute it and/or modify
|
|
| 10 |
+ * it under the terms of the GNU General Public License as
|
|
| 11 |
+ * published by the Free Software Foundation, either version 3 of the
|
|
| 12 |
+ * License, or (at your option) any later version.
|
|
| 13 |
+ *
|
|
| 14 |
+ * This program is distributed in the hope that it will be useful,
|
|
| 15 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 16 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 17 |
+ * GNU General Public License for more details.
|
|
| 18 |
+ *
|
|
| 19 |
+ * You should have received a copy of the GNU General Public
|
|
| 20 |
+ * License along with this program. If not, see
|
|
| 21 |
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 22 |
+ * #L%
|
|
| 23 |
+ */
|
|
| 24 |
+ |
|
| 25 |
+import fr.ird.observe.client.datasource.editor.content.ObserveLLKeyStrokes;
|
|
| 26 |
+import fr.ird.observe.client.datasource.editor.content.data.ll.observation.SensorUsedUI;
|
|
| 27 |
+import fr.ird.observe.client.util.ObserveSwingTechnicalException;
|
|
| 28 |
+import fr.ird.observe.client.util.UIHelper;
|
|
| 29 |
+import fr.ird.observe.dto.data.DataFileDto;
|
|
| 30 |
+import fr.ird.observe.dto.data.ll.observation.SensorUsedDto;
|
|
| 31 |
+import org.apache.logging.log4j.LogManager;
|
|
| 32 |
+import org.apache.logging.log4j.Logger;
|
|
| 33 |
+import org.nuiton.jaxx.widgets.file.JaxxFileChooser;
|
|
| 34 |
+ |
|
| 35 |
+import java.awt.event.ActionEvent;
|
|
| 36 |
+import java.io.File;
|
|
| 37 |
+import java.io.IOException;
|
|
| 38 |
+import java.nio.file.Files;
|
|
| 39 |
+ |
|
| 40 |
+import static io.ultreia.java4all.i18n.I18n.n;
|
|
| 41 |
+import static io.ultreia.java4all.i18n.I18n.t;
|
|
| 42 |
+ |
|
| 43 |
+/**
|
|
| 44 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 45 |
+ * @since 8
|
|
| 46 |
+ */
|
|
| 47 |
+public class SensorUsedUIExportData extends SensorUsedUIActionSupport {
|
|
| 48 |
+ |
|
| 49 |
+ private static final Logger log = LogManager.getLogger(SensorUsedUIExportData.class);
|
|
| 50 |
+ |
|
| 51 |
+ public SensorUsedUIExportData() {
|
|
| 52 |
+ super(n("observe.data.ll.observation.SensorUsed.exportData"), n("observe.data.ll.observation.SensorUsed.exportData.tip"), "data-export", ObserveLLKeyStrokes.KEY_STROKE_EXPORT_DATA);
|
|
| 53 |
+ }
|
|
| 54 |
+ |
|
| 55 |
+ @Override
|
|
| 56 |
+ protected void doActionPerformed(ActionEvent event, SensorUsedUI ui) {
|
|
| 57 |
+ |
|
| 58 |
+ SensorUsedDto tableEditBean = ui.getModel().getTableEditBean();
|
|
| 59 |
+ DataFileDto dataFile = tableEditBean.getData();
|
|
| 60 |
+ if (dataFile == null) {
|
|
| 61 |
+ dataFile = getDataSource().getLlObservationActivitySensorUsedService().getDataFile(tableEditBean.getId());
|
|
| 62 |
+ }
|
|
| 63 |
+ File file = JaxxFileChooser
|
|
| 64 |
+ .forSaving()
|
|
| 65 |
+ .setParent(ui)
|
|
| 66 |
+ .setTitle(t("observe.data.ll.observation.SensorUsed.choose.title.exportData"))
|
|
| 67 |
+ .setApprovalText(t("observe.data.ll.observation.SensorUsed.action.exportData"))
|
|
| 68 |
+ .setFilename(dataFile.getName())
|
|
| 69 |
+ .setUseAcceptAllFileFilter(true)
|
|
| 70 |
+ .choose();
|
|
| 71 |
+ |
|
| 72 |
+ if (file != null && UIHelper.confirmOverwriteFileIfExist(ui, file)) {
|
|
| 73 |
+ log.info(String.format("%s save sensorUsed data to %s", ui.getModel().getPrefix(), file));
|
|
| 74 |
+ try {
|
|
| 75 |
+ Files.write(file.toPath(), dataFile.getContent());
|
|
| 76 |
+ } catch (IOException e) {
|
|
| 77 |
+ throw new ObserveSwingTechnicalException("Could not save binary data to " + file, e);
|
|
| 78 |
+ }
|
|
| 79 |
+ }
|
|
| 80 |
+ }
|
|
| 81 |
+}
|
| 1 |
+package fr.ird.observe.client.datasource.editor.content.data.ll.observation.actions;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client DataSource Editor LL
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2020 IRD, Code Lutin, Ultreia.io
|
|
| 8 |
+ * %%
|
|
| 9 |
+ * This program is free software: you can redistribute it and/or modify
|
|
| 10 |
+ * it under the terms of the GNU General Public License as
|
|
| 11 |
+ * published by the Free Software Foundation, either version 3 of the
|
|
| 12 |
+ * License, or (at your option) any later version.
|
|
| 13 |
+ *
|
|
| 14 |
+ * This program is distributed in the hope that it will be useful,
|
|
| 15 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 16 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 17 |
+ * GNU General Public License for more details.
|
|
| 18 |
+ *
|
|
| 19 |
+ * You should have received a copy of the GNU General Public
|
|
| 20 |
+ * License along with this program. If not, see
|
|
| 21 |
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 22 |
+ * #L%
|
|
| 23 |
+ */
|
|
| 24 |
+ |
|
| 25 |
+import fr.ird.observe.client.datasource.editor.content.ObserveLLKeyStrokes;
|
|
| 26 |
+import fr.ird.observe.client.datasource.editor.content.data.ll.observation.SensorUsedUI;
|
|
| 27 |
+import fr.ird.observe.client.util.UIHelper;
|
|
| 28 |
+import fr.ird.observe.dto.data.DataFileDto;
|
|
| 29 |
+import fr.ird.observe.dto.data.ll.observation.SensorUsedDto;
|
|
| 30 |
+import org.apache.logging.log4j.LogManager;
|
|
| 31 |
+import org.apache.logging.log4j.Logger;
|
|
| 32 |
+ |
|
| 33 |
+import javax.swing.JOptionPane;
|
|
| 34 |
+import java.awt.event.ActionEvent;
|
|
| 35 |
+import java.io.File;
|
|
| 36 |
+ |
|
| 37 |
+import static io.ultreia.java4all.i18n.I18n.n;
|
|
| 38 |
+import static io.ultreia.java4all.i18n.I18n.t;
|
|
| 39 |
+ |
|
| 40 |
+/**
|
|
| 41 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 42 |
+ * @since 8
|
|
| 43 |
+ */
|
|
| 44 |
+public class SensorUsedUIImportData extends SensorUsedUIActionSupport {
|
|
| 45 |
+ |
|
| 46 |
+ private static final Logger log = LogManager.getLogger(SensorUsedUIImportData.class);
|
|
| 47 |
+ |
|
| 48 |
+ public SensorUsedUIImportData() {
|
|
| 49 |
+ super(n("observe.data.ll.observation.SensorUsed.importData"), n("observe.data.ll.observation.SensorUsed.importData.tip"), "data-import", ObserveLLKeyStrokes.KEY_STROKE_IMPORT_DATA);
|
|
| 50 |
+ }
|
|
| 51 |
+ |
|
| 52 |
+ @Override
|
|
| 53 |
+ protected void doActionPerformed(ActionEvent e, SensorUsedUI ui) {
|
|
| 54 |
+ SensorUsedDto tableEditBean = ui.getModel().getTableEditBean();
|
|
| 55 |
+ if (tableEditBean.isHasData()) {
|
|
| 56 |
+ DataFileDto dataFile = tableEditBean.getData();
|
|
| 57 |
+ if (dataFile == null) {
|
|
| 58 |
+ dataFile = getDataSource().getLlObservationActivitySensorUsedService().getDataFile(tableEditBean.getId());
|
|
| 59 |
+ }
|
|
| 60 |
+ int response = UIHelper.askUser(ui,
|
|
| 61 |
+ t("observe.title.confirmReplace"),
|
|
| 62 |
+ t("observe.data.ll.observation.SensorUsed.replace.data.message", dataFile.getName()),
|
|
| 63 |
+ JOptionPane.WARNING_MESSAGE,
|
|
| 64 |
+ new Object[]{t("observe.choice.confirm.replace"),
|
|
| 65 |
+ t("observe.choice.cancel")},
|
|
| 66 |
+ 1);
|
|
| 67 |
+ boolean doReplace = response == 0;
|
|
| 68 |
+ if (!doReplace) {
|
|
| 69 |
+ return;
|
|
| 70 |
+ }
|
|
| 71 |
+ }
|
|
| 72 |
+ |
|
| 73 |
+ File file = UIHelper.chooseFile(ui,
|
|
| 74 |
+ t("observe.data.ll.observation.SensorUsed.choose.title.importData"),
|
|
| 75 |
+ t("observe.data.ll.observation.SensorUsed.action.importData"),
|
|
| 76 |
+ null,
|
|
| 77 |
+ null);
|
|
| 78 |
+ if (file != null) {
|
|
| 79 |
+ log.info(String.format("%s Import sensorUsed data from file: %s", ui.getModel().getPrefix(), file));
|
|
| 80 |
+ DataFileDto dataFileDto = UIHelper.fileToDataFileDto(file);
|
|
| 81 |
+ tableEditBean.setData(dataFileDto);
|
|
| 82 |
+ tableEditBean.setHasData(true);
|
|
| 83 |
+ }
|
|
| 84 |
+ }
|
|
| 85 |
+}
|
| 1 |
+package fr.ird.observe.client.datasource.editor.content.data.ll.observation.actions;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client DataSource Editor LL
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2020 IRD, Code Lutin, Ultreia.io
|
|
| 8 |
+ * %%
|
|
| 9 |
+ * This program is free software: you can redistribute it and/or modify
|
|
| 10 |
+ * it under the terms of the GNU General Public License as
|
|
| 11 |
+ * published by the Free Software Foundation, either version 3 of the
|
|
| 12 |
+ * License, or (at your option) any later version.
|
|
| 13 |
+ *
|
|
| 14 |
+ * This program is distributed in the hope that it will be useful,
|
|
| 15 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 16 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 17 |
+ * GNU General Public License for more details.
|
|
| 18 |
+ *
|
|
| 19 |
+ * You should have received a copy of the GNU General Public
|
|
| 20 |
+ * License along with this program. If not, see
|
|
| 21 |
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 22 |
+ * #L%
|
|
| 23 |
+ */
|
|
| 24 |
+ |
|
| 25 |
+import fr.ird.observe.client.datasource.editor.content.actions.ContentUIActionSupport;
|
|
| 26 |
+import fr.ird.observe.client.datasource.editor.content.data.ll.observation.TdrUI;
|
|
| 27 |
+ |
|
| 28 |
+import javax.swing.KeyStroke;
|
|
| 29 |
+ |
|
| 30 |
+/**
|
|
| 31 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 32 |
+ * @since 8
|
|
| 33 |
+ */
|
|
| 34 |
+public abstract class TdrUIActionSupport extends ContentUIActionSupport<TdrUI> {
|
|
| 35 |
+ |
|
| 36 |
+ protected TdrUIActionSupport(String label, String shortDescription, String actionIcon, KeyStroke acceleratorKey) {
|
|
| 37 |
+ super(label, shortDescription, actionIcon, acceleratorKey);
|
|
| 38 |
+ }
|
|
| 39 |
+ |
|
| 40 |
+ protected TdrUIActionSupport(String actionCommandKey, String label, String shortDescription, String actionIcon, KeyStroke acceleratorKey) {
|
|
| 41 |
+ super(actionCommandKey, label, shortDescription, actionIcon, acceleratorKey);
|
|
| 42 |
+ }
|
|
| 43 |
+ |
|
| 44 |
+ protected TdrUIActionSupport(String label, String shortDescription, String actionIcon, char acceleratorKey) {
|
|
| 45 |
+ super(label, shortDescription, actionIcon, acceleratorKey);
|
|
| 46 |
+ }
|
|
| 47 |
+ |
|
| 48 |
+ protected TdrUIActionSupport(String actionCommandKey, String label, String shortDescription, String actionIcon, char acceleratorKey) {
|
|
| 49 |
+ super(actionCommandKey, label, shortDescription, actionIcon, acceleratorKey);
|
|
| 50 |
+ }
|
|
| 51 |
+}
|
|
| 52 |
+ |
| 1 |
+package fr.ird.observe.client.datasource.editor.content.data.ll.observation.actions;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client DataSource Editor LL
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2020 IRD, Code Lutin, Ultreia.io
|
|
| 8 |
+ * %%
|
|
| 9 |
+ * This program is free software: you can redistribute it and/or modify
|
|
| 10 |
+ * it under the terms of the GNU General Public License as
|
|
| 11 |
+ * published by the Free Software Foundation, either version 3 of the
|
|
| 12 |
+ * License, or (at your option) any later version.
|
|
| 13 |
+ *
|
|
| 14 |
+ * This program is distributed in the hope that it will be useful,
|
|
| 15 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 16 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 17 |
+ * GNU General Public License for more details.
|
|
| 18 |
+ *
|
|
| 19 |
+ * You should have received a copy of the GNU General Public
|
|
| 20 |
+ * License along with this program. If not, see
|
|
| 21 |
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 22 |
+ * #L%
|
|
| 23 |
+ */
|
|
| 24 |
+ |
|
| 25 |
+import fr.ird.observe.client.datasource.editor.content.ObserveLLKeyStrokes;
|
|
| 26 |
+import fr.ird.observe.client.datasource.editor.content.data.ll.observation.TdrUI;
|
|
| 27 |
+import fr.ird.observe.client.util.UIHelper;
|
|
| 28 |
+import fr.ird.observe.dto.data.ll.observation.TdrDto;
|
|
| 29 |
+import org.apache.logging.log4j.LogManager;
|
|
| 30 |
+import org.apache.logging.log4j.Logger;
|
|
| 31 |
+ |
|
| 32 |
+import javax.swing.JOptionPane;
|
|
| 33 |
+import java.awt.event.ActionEvent;
|
|
| 34 |
+ |
|
| 35 |
+import static io.ultreia.java4all.i18n.I18n.n;
|
|
| 36 |
+import static io.ultreia.java4all.i18n.I18n.t;
|
|
| 37 |
+ |
|
| 38 |
+/**
|
|
| 39 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 40 |
+ * @since 8
|
|
| 41 |
+ */
|
|
| 42 |
+public class TdrUIDeleteData extends TdrUIActionSupport {
|
|
| 43 |
+ |
|
| 44 |
+ private static final Logger log = LogManager.getLogger(TdrUIDeleteData.class);
|
|
| 45 |
+ |
|
| 46 |
+ public TdrUIDeleteData() {
|
|
| 47 |
+ super(n("observe.data.ll.observation.Tdr.deleteData"), n("observe.data.ll.observation.Tdr.deleteData.tip"), "delete", ObserveLLKeyStrokes.KEY_STROKE_DELETE_DATA);
|
|
| 48 |
+ }
|
|
| 49 |
+ |
|
| 50 |
+ @Override
|
|
| 51 |
+ protected void doActionPerformed(ActionEvent e, TdrUI ui) {
|
|
| 52 |
+ int response = UIHelper.askUser(ui,
|
|
| 53 |
+ t("observe.title.delete"),
|
|
| 54 |
+ t("observe.data.ll.observation.SensorUsed.delete.data.message"),
|
|
| 55 |
+ JOptionPane.WARNING_MESSAGE,
|
|
| 56 |
+ new Object[]{t("observe.choice.confirm.delete"),
|
|
| 57 |
+ t("observe.choice.cancel")},
|
|
| 58 |
+ 1);
|
|
| 59 |
+ boolean doDelete = response == 0;
|
|
| 60 |
+ if (doDelete) {
|
|
| 61 |
+ TdrDto tableEditBean = ui.getModel().getTableEditBean();
|
|
| 62 |
+ log.info(String.format("%s Delete tdr data %s", ui.getModel().getPrefix(), tableEditBean.getData()));
|
|
| 63 |
+ tableEditBean.setData(null);
|
|
| 64 |
+ tableEditBean.setHasData(false);
|
|
| 65 |
+ }
|
|
| 66 |
+ }
|
|
| 67 |
+}
|
| 1 |
+package fr.ird.observe.client.datasource.editor.content.data.ll.observation.actions;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client DataSource Editor LL
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2020 IRD, Code Lutin, Ultreia.io
|
|
| 8 |
+ * %%
|
|
| 9 |
+ * This program is free software: you can redistribute it and/or modify
|
|
| 10 |
+ * it under the terms of the GNU General Public License as
|
|
| 11 |
+ * published by the Free Software Foundation, either version 3 of the
|
|
| 12 |
+ * License, or (at your option) any later version.
|
|
| 13 |
+ *
|
|
| 14 |
+ * This program is distributed in the hope that it will be useful,
|
|
| 15 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 16 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 17 |
+ * GNU General Public License for more details.
|
|
| 18 |
+ *
|
|
| 19 |
+ * You should have received a copy of the GNU General Public
|
|
| 20 |
+ * License along with this program. If not, see
|
|
| 21 |
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 22 |
+ * #L%
|
|
| 23 |
+ */
|
|
| 24 |
+ |
|
| 25 |
+import fr.ird.observe.client.datasource.editor.content.ObserveLLKeyStrokes;
|
|
| 26 |
+import fr.ird.observe.client.datasource.editor.content.data.ll.observation.TdrUI;
|
|
| 27 |
+import fr.ird.observe.client.util.ObserveSwingTechnicalException;
|
|
| 28 |
+import fr.ird.observe.client.util.UIHelper;
|
|
| 29 |
+import fr.ird.observe.dto.data.DataFileDto;
|
|
| 30 |
+import fr.ird.observe.dto.data.ll.observation.TdrDto;
|
|
| 31 |
+import org.apache.logging.log4j.LogManager;
|
|
| 32 |
+import org.apache.logging.log4j.Logger;
|
|
| 33 |
+import org.nuiton.jaxx.widgets.file.JaxxFileChooser;
|
|
| 34 |
+ |
|
| 35 |
+import java.awt.event.ActionEvent;
|
|
| 36 |
+import java.io.File;
|
|
| 37 |
+import java.io.IOException;
|
|
| 38 |
+import java.nio.file.Files;
|
|
| 39 |
+ |
|
| 40 |
+import static io.ultreia.java4all.i18n.I18n.n;
|
|
| 41 |
+import static io.ultreia.java4all.i18n.I18n.t;
|
|
| 42 |
+ |
|
| 43 |
+/**
|
|
| 44 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 45 |
+ * @since 8
|
|
| 46 |
+ */
|
|
| 47 |
+public class TdrUIExportData extends TdrUIActionSupport {
|
|
| 48 |
+ |
|
| 49 |
+ private static final Logger log = LogManager.getLogger(TdrUIExportData.class);
|
|
| 50 |
+ |
|
| 51 |
+ public TdrUIExportData() {
|
|
| 52 |
+ super(n("observe.data.ll.observation.Tdr.exportData"), n("observe.data.ll.observation.Tdr.exportData.tip"), "data-export", ObserveLLKeyStrokes.KEY_STROKE_EXPORT_DATA);
|
|
| 53 |
+ }
|
|
| 54 |
+ |
|
| 55 |
+ @Override
|
|
| 56 |
+ protected void doActionPerformed(ActionEvent event, TdrUI ui) {
|
|
| 57 |
+ |
|
| 58 |
+ TdrDto tableEditBean = ui.getModel().getTableEditBean();
|
|
| 59 |
+ DataFileDto dataFile = tableEditBean.getData();
|
|
| 60 |
+ |
|
| 61 |
+ if (dataFile == null) {
|
|
| 62 |
+ dataFile = getDataSource().getLlObservationSetTdrService().getDataFile(tableEditBean.getId());
|
|
| 63 |
+ }
|
|
| 64 |
+ |
|
| 65 |
+ File file = JaxxFileChooser
|
|
| 66 |
+ .forSaving()
|
|
| 67 |
+ .setParent(ui)
|
|
| 68 |
+ .setTitle(t("observe.data.ll.observation.Tdr.choose.title.exportData"))
|
|
| 69 |
+ .setApprovalText(t("observe.data.ll.observation.Tdr.action.exportData"))
|
|
| 70 |
+ .setFilename(dataFile.getName())
|
|
| 71 |
+ .setUseAcceptAllFileFilter(true)
|
|
| 72 |
+ .choose();
|
|
| 73 |
+ |
|
| 74 |
+ if (file != null && UIHelper.confirmOverwriteFileIfExist(ui, file)) {
|
|
| 75 |
+ try {
|
|
| 76 |
+ log.info(String.format("%s save tdr data to %s", ui.getModel().getPrefix(), file));
|
|
| 77 |
+ Files.write(file.toPath(), dataFile.getContent());
|
|
| 78 |
+ } catch (IOException e) {
|
|
| 79 |
+ throw new ObserveSwingTechnicalException("Could not save binary data to " + file, e);
|
|
| 80 |
+ }
|
|
| 81 |
+ }
|
|
| 82 |
+ }
|
|
| 83 |
+}
|
| 1 |
+package fr.ird.observe.client.datasource.editor.content.data.ll.observation.actions;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client DataSource Editor LL
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2020 IRD, Code Lutin, Ultreia.io
|
|
| 8 |
+ * %%
|
|
| 9 |
+ * This program is free software: you can redistribute it and/or modify
|
|
| 10 |
+ * it under the terms of the GNU General Public License as
|
|
| 11 |
+ * published by the Free Software Foundation, either version 3 of the
|
|
| 12 |
+ * License, or (at your option) any later version.
|
|
| 13 |
+ *
|
|
| 14 |
+ * This program is distributed in the hope that it will be useful,
|
|
| 15 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 16 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 17 |
+ * GNU General Public License for more details.
|
|
| 18 |
+ *
|
|
| 19 |
+ * You should have received a copy of the GNU General Public
|
|
| 20 |
+ * License along with this program. If not, see
|
|
| 21 |
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 22 |
+ * #L%
|
|
| 23 |
+ */
|
|
| 24 |
+ |
|
| 25 |
+import fr.ird.observe.client.datasource.editor.content.ObserveLLKeyStrokes;
|
|
| 26 |
+import fr.ird.observe.client.datasource.editor.content.data.ll.observation.TdrUI;
|
|
| 27 |
+import fr.ird.observe.client.util.UIHelper;
|
|
| 28 |
+import fr.ird.observe.dto.data.DataFileDto;
|
|
| 29 |
+import fr.ird.observe.dto.data.ll.observation.TdrDto;
|
|
| 30 |
+import org.apache.logging.log4j.LogManager;
|
|
| 31 |
+import org.apache.logging.log4j.Logger;
|
|
| 32 |
+ |
|
| 33 |
+import javax.swing.JOptionPane;
|
|
| 34 |
+import java.awt.event.ActionEvent;
|
|
| 35 |
+import java.io.File;
|
|
| 36 |
+ |
|
| 37 |
+import static io.ultreia.java4all.i18n.I18n.n;
|
|
| 38 |
+import static io.ultreia.java4all.i18n.I18n.t;
|
|
| 39 |
+ |
|
| 40 |
+/**
|
|
| 41 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 42 |
+ * @since 8
|
|
| 43 |
+ */
|
|
| 44 |
+public class TdrUIImportData extends TdrUIActionSupport {
|
|
| 45 |
+ |
|
| 46 |
+ private static final Logger log = LogManager.getLogger(TdrUIImportData.class);
|
|
| 47 |
+ |
|
| 48 |
+ public TdrUIImportData() {
|
|
| 49 |
+ super(n("observe.data.ll.observation.Tdr.importData"), n("observe.data.ll.observation.Tdr.importData.tip"), "data-import", ObserveLLKeyStrokes.KEY_STROKE_IMPORT_DATA);
|
|
| 50 |
+ }
|
|
| 51 |
+ |
|
| 52 |
+ @Override
|
|
| 53 |
+ protected void doActionPerformed(ActionEvent e, TdrUI ui) {
|
|
| 54 |
+ TdrDto tableEditBean = ui.getModel().getTableEditBean();
|
|
| 55 |
+ if (tableEditBean.isHasData()) {
|
|
| 56 |
+ DataFileDto dataFile = tableEditBean.getData();
|
|
| 57 |
+ if (dataFile == null) {
|
|
| 58 |
+ dataFile = getDataSource().getLlObservationSetTdrService().getDataFile(tableEditBean.getId());
|
|
| 59 |
+ }
|
|
| 60 |
+ int response = UIHelper.askUser(ui,
|
|
| 61 |
+ t("observe.title.confirmReplace"),
|
|
| 62 |
+ t("observe.data.ll.observation.Tdr.replace.data.message", dataFile.getName()),
|
|
| 63 |
+ JOptionPane.WARNING_MESSAGE,
|
|
| 64 |
+ new Object[]{t("observe.choice.confirm.replace"),
|
|
| 65 |
+ t("observe.choice.cancel")},
|
|
| 66 |
+ 1);
|
|
| 67 |
+ boolean doReplace = response == 0;
|
|
| 68 |
+ if (!doReplace) {
|
|
| 69 |
+ return;
|
|
| 70 |
+ }
|
|
| 71 |
+ }
|
|
| 72 |
+ |
|
| 73 |
+ File file = UIHelper.chooseFile(ui,
|
|
| 74 |
+ t("observe.data.ll.observation.Tdr.choose.title.importData"),
|
|
| 75 |
+ t("observe.data.ll.observation.Tdr.action.importData"),
|
|
| 76 |
+ null,
|
|
| 77 |
+ null);
|
|
| 78 |
+ if (file != null) {
|
|
| 79 |
+ log.info(String.format("%s Import tdr data from file: %s", ui.getModel().getPrefix(), file));
|
|
| 80 |
+ DataFileDto dataFileDto = UIHelper.fileToDataFileDto(file);
|
|
| 81 |
+ tableEditBean.setData(dataFileDto);
|
|
| 82 |
+ tableEditBean.setHasData(true);
|
|
| 83 |
+ }
|
|
| 84 |
+ }
|
|
| 85 |
+}
|
| ... | ... | @@ -100,41 +100,6 @@ |
| 100 | 100 |
<message/>
|
| 101 | 101 |
</field-validator>
|
| 102 | 102 |
</field>
|
| 103 |
- <field name="haulingStartTimeStamp">
|
|
| 104 |
- <field-validator type="mandatory" short-circuit="true">
|
|
| 105 |
- <message/>
|
|
| 106 |
- </field-validator>
|
|
| 107 |
- |
|
| 108 |
- <!-- settingEndTimeStamp < haulingStartTimeStamp -->
|
|
| 109 |
- <field-validator type="fieldexpression" short-circuit="true">
|
|
| 110 |
- <param name="expression">
|
|
| 111 |
- <![CDATA[ settingEndTimeStamp == null || settingEndTimeStamp.time < haulingStartTimeStamp.time ]]>
|
|
| 112 |
- </param>
|
|
| 113 |
- <message>observe.validation.setLongline.settingEndTimeStamp.before.haulingStartTimeStamp</message>
|
|
| 114 |
- </field-validator>
|
|
| 115 |
- </field>
|
|
| 116 |
- <field name="haulingEndTimeStamp">
|
|
| 117 |
- <field-validator type="mandatory" short-circuit="true">
|
|
| 118 |
- <message/>
|
|
| 119 |
- </field-validator>
|
|
| 120 |
- |
|
| 121 |
- <!-- haulingStartTimeStamp < haulingEndTimeStamp -->
|
|
| 122 |
- <field-validator type="fieldexpression" short-circuit="true">
|
|
| 123 |
- <param name="expression">
|
|
| 124 |
- <![CDATA[ haulingStartTimeStamp == null || haulingStartTimeStamp.time < haulingEndTimeStamp.time ]]>
|
|
| 125 |
- </param>
|
|
| 126 |
- <message>observe.validation.setLongline.haulingStartTimeStamp.before.haulingEndTimeStamp</message>
|
|
| 127 |
- </field-validator>
|
|
| 128 |
- </field>
|
|
| 129 |
- <field name="settingStartQuadrant">
|
|
| 130 |
- <field-validator type="mandatory" short-circuit="true">
|
|
| 131 |
- <message/>
|
|
| 132 |
- </field-validator>
|
|
| 133 |
- <field-validator type="quadrantDto" short-circuit="true">
|
|
| 134 |
- <param name="ocean">currentLlCommonTrip.ocean</param>
|
|
| 135 |
- <message/>
|
|
| 136 |
- </field-validator>
|
|
| 137 |
- </field>
|
|
| 138 | 103 |
<field name="settingStartLatitude">
|
| 139 | 104 |
<field-validator type="mandatory" short-circuit="true">
|
| 140 | 105 |
<message/>
|
| ... | ... | @@ -153,7 +118,7 @@ |
| 153 | 118 |
<message/>
|
| 154 | 119 |
</field-validator>
|
| 155 | 120 |
</field>
|
| 156 |
- <field name="settingEndQuadrant">
|
|
| 121 |
+ <field name="settingStartQuadrant">
|
|
| 157 | 122 |
<field-validator type="mandatory" short-circuit="true">
|
| 158 | 123 |
<message/>
|
| 159 | 124 |
</field-validator>
|
| ... | ... | @@ -180,7 +145,7 @@ |
| 180 | 145 |
<message/>
|
| 181 | 146 |
</field-validator>
|
| 182 | 147 |
</field>
|
| 183 |
- <field name="haulingStartQuadrant">
|
|
| 148 |
+ <field name="settingEndQuadrant">
|
|
| 184 | 149 |
<field-validator type="mandatory" short-circuit="true">
|
| 185 | 150 |
<message/>
|
| 186 | 151 |
</field-validator>
|
| ... | ... | @@ -207,7 +172,7 @@ |
| 207 | 172 |
<message/>
|
| 208 | 173 |
</field-validator>
|
| 209 | 174 |
</field>
|
| 210 |
- <field name="haulingEndQuadrant">
|
|
| 175 |
+ <field name="haulingStartQuadrant">
|
|
| 211 | 176 |
<field-validator type="mandatory" short-circuit="true">
|
| 212 | 177 |
<message/>
|
| 213 | 178 |
</field-validator>
|
| ... | ... | @@ -234,6 +199,15 @@ |
| 234 | 199 |
<message/>
|
| 235 | 200 |
</field-validator>
|
| 236 | 201 |
</field>
|
| 202 |
+ <field name="haulingEndQuadrant">
|
|
| 203 |
+ <field-validator type="mandatory" short-circuit="true">
|
|
| 204 |
+ <message/>
|
|
| 205 |
+ </field-validator>
|
|
| 206 |
+ <field-validator type="quadrantDto" short-circuit="true">
|
|
| 207 |
+ <param name="ocean">currentLlCommonTrip.ocean</param>
|
|
| 208 |
+ <message/>
|
|
| 209 |
+ </field-validator>
|
|
| 210 |
+ </field>
|
|
| 237 | 211 |
<field name="totalSectionsCount">
|
| 238 | 212 |
<field-validator type="mandatory" short-circuit="true">
|
| 239 | 213 |
<message/>
|
| ... | ... | @@ -267,7 +241,7 @@ |
| 267 | 241 |
<field name="totalBasketsCount">
|
| 268 | 242 |
<field-validator type="boundNumber" short-circuit="true">
|
| 269 | 243 |
<param name="min">0.0</param>
|
| 270 |
- <param name="max">1000.0</param>
|
|
| 244 |
+ <param name="max">400.0</param>
|
|
| 271 | 245 |
<message/>
|
| 272 | 246 |
</field-validator>
|
| 273 | 247 |
</field>
|
| ... | ... | @@ -49,6 +49,7 @@ |
| 49 | 49 |
<field-validator type="mandatory" short-circuit="true">
|
| 50 | 50 |
<message/>
|
| 51 | 51 |
</field-validator>
|
| 52 |
+ |
|
| 52 | 53 |
<!-- settingStartTimeStamp < settingEndTimeStamp -->
|
| 53 | 54 |
<field-validator type="fieldexpression" short-circuit="true">
|
| 54 | 55 |
<param name="expression">
|
| ... | ... | @@ -57,30 +58,6 @@ |
| 57 | 58 |
<message>observe.validation.setLongline.settingStartTimeStamp.before.settingEndTimeStamp</message>
|
| 58 | 59 |
</field-validator>
|
| 59 | 60 |
</field>
|
| 60 |
- <field name="haulingStartTimeStamp">
|
|
| 61 |
- <field-validator type="mandatory" short-circuit="true">
|
|
| 62 |
- <message/>
|
|
| 63 |
- </field-validator>
|
|
| 64 |
- <!-- settingEndTimeStamp < haulingStartTimeStamp -->
|
|
| 65 |
- <field-validator type="fieldexpression" short-circuit="true">
|
|
| 66 |
- <param name="expression">
|
|
| 67 |
- <![CDATA[ settingEndTimeStamp == null || settingEndTimeStamp.time < haulingStartTimeStamp.time ]]>
|
|
| 68 |
- </param>
|
|
| 69 |
- <message>observe.validation.setLongline.settingEndTimeStamp.before.haulingStartTimeStamp</message>
|
|
| 70 |
- </field-validator>
|
|
| 71 |
- </field>
|
|
| 72 |
- <field name="haulingEndTimeStamp">
|
|
| 73 |
- <field-validator type="mandatory" short-circuit="true">
|
|
| 74 |
- <message/>
|
|
| 75 |
- </field-validator>
|
|
| 76 |
- <!-- haulingStartTimeStamp < haulingEndTimeStamp -->
|
|
| 77 |
- <field-validator type="fieldexpression" short-circuit="true">
|
|
| 78 |
- <param name="expression">
|
|
| 79 |
- <![CDATA[ haulingStartTimeStamp == null || haulingStartTimeStamp.time < haulingEndTimeStamp.time ]]>
|
|
| 80 |
- </param>
|
|
| 81 |
- <message>observe.validation.setLongline.haulingStartTimeStamp.before.haulingEndTimeStamp</message>
|
|
| 82 |
- </field-validator>
|
|
| 83 |
- </field>
|
|
| 84 | 61 |
<field name="settingVesselSpeed">
|
| 85 | 62 |
<field-validator type="boundNumber" short-circuit="true">
|
| 86 | 63 |
<param name="min">0.0</param>
|
| ... | ... | @@ -264,7 +241,7 @@ |
| 264 | 241 |
<field name="totalBasketsCount">
|
| 265 | 242 |
<field-validator type="boundNumber" short-circuit="true">
|
| 266 | 243 |
<param name="min">0.0</param>
|
| 267 |
- <param name="max">1000.0</param>
|
|
| 244 |
+ <param name="max">400.0</param>
|
|
| 268 | 245 |
<message/>
|
| 269 | 246 |
</field-validator>
|
| 270 | 247 |
</field>
|