Tutti-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- 4058 discussions
r1223 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing java/fr/ifremer/tutti/ui/swing/content java/fr/ifremer/tutti/ui/swing/content/db resources/i18n
by tchemit@users.forge.codelutin.com 25 Sep '13
by tchemit@users.forge.codelutin.com 25 Sep '13
25 Sep '13
Author: tchemit
Date: 2013-09-25 15:31:19 +0200 (Wed, 25 Sep 2013)
New Revision: 1223
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1223
Log:
fixes #3317: [TECH] - Mise ?\195?\160 jour de la base de donn?\195?\169es : pas de v?\195?\169rification au lancement
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiDbUpdaterCallBack.java
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateApplicationAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateDbAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/InstallDbAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -102,15 +102,6 @@
// check application url is reachable
boolean canUpdate = context.checkUpdateApplicationReachable();
-// try {
-// TuttiUIUtil.tryToConnectToUpdateUrl(
-// config.getUpdateApplicationUrl(),
-// n_("tutti.error.update.could.not.reach.url")
-// );
-// } catch (TuttiBusinessException e) {
-// TuttiUIContext.getErrorHelper().showWarningDialog(e.getMessage());
-// canUpdate = false;
-// }
if (canUpdate) {
// try to update jre - i18n - application - help and exit if so
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -29,24 +29,16 @@
import com.google.common.collect.Maps;
import fr.ifremer.tutti.LabelAware;
import fr.ifremer.tutti.TuttiIOUtil;
-import fr.ifremer.tutti.TuttiTechnicalException;
import fr.ifremer.tutti.persistence.ProgressionModel;
import fr.ifremer.tutti.persistence.config.TuttiPersistenceConfig;
-import fr.ifremer.tutti.persistence.service.synchro.ReferentialSynchronizeResult;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.service.referential.TuttiReferentialSynchronizeService;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionException;
-import fr.ifremer.tutti.ui.swing.util.action.TuttiActionUI;
-import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.updater.ApplicationInfo;
-import org.nuiton.updater.ApplicationUpdater;
import org.nuiton.updater.ApplicationUpdaterCallback;
import java.io.File;
-import java.io.IOException;
import java.util.List;
import java.util.Map;
@@ -54,7 +46,7 @@
import static org.nuiton.i18n.I18n.n_;
/**
- * CallBack to update jre, application, i18n or db.
+ * CallBack to update jre, application, i18n.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 1.0
@@ -69,8 +61,7 @@
JRE(n_("tutti.update.jre")),
TUTTI(n_("tutti.update.tutti")),
I18N(n_("tutti.update.i18n")),
- HELP(n_("tutti.update.help")),
- DB(n_("tutti.update.db"));
+ HELP(n_("tutti.update.help"));
private final String i18nKey;
@@ -92,10 +83,6 @@
protected boolean applicationUpdated;
- protected boolean dbInstalled;
-
- protected boolean dbUpdated;
-
protected final AbstractTuttiAction action;
public TuttiApplicationUpdaterCallBack(AbstractTuttiAction action,
@@ -113,14 +100,6 @@
return applicationUpdated;
}
- public boolean isDbUpdated() {
- return dbUpdated;
- }
-
- public boolean isDbInstalled() {
- return dbInstalled;
- }
-
@Override
public Map<String, ApplicationInfo> updateToDo(Map<String, ApplicationInfo> appToUpdate) {
Map<String, ApplicationInfo> result = Maps.newHashMap();
@@ -129,48 +108,13 @@
ApplicationInfo info = getInfo(type, appToUpdate);
if (info != null) {
result.put(info.name, info);
- if (UpdateType.DB.equals(type)) {
- // add auth
- info.setAuthentication(
- "t" + "u" + "t" + "t" + "i" + "d" + "b",
- new char[]{'3', 'R', 'A', 'C', 'e', 'v', '2', 'N', 'w', '8', 'u', 'E', 'D', 'E', 'v', 's', 'y', '0', 'v', 'J'}
- );
- }
}
}
- if (types.contains(UpdateType.DB)) {
-
- ApplicationInfo info = getInfo(UpdateType.DB, result);
-
- if (info == null) {
- dbInstalled = false;
- dbUpdated = false;
- } else {
- if (context.isDbExist()) {
-
- // when db exists always an update
- dbUpdated = true;
- } else {
-
- // when no db, then always install
- dbInstalled = true;
- }
- }
- }
return result;
}
@Override
public void startUpdate(ApplicationInfo info) {
- if (UpdateType.DB.name().toLowerCase().equals(info.name)) {
-
- if (dbInstalled) {
-
- progressionModel.setMessage(_("tutti.applicationUpdater.startUpdate.db.installation", info.newVersion));
- } else if (dbUpdated) {
- progressionModel.setMessage(_("tutti.applicationUpdater.startUpdate.db.update", info.newVersion));
- }
- }
if (UpdateType.JRE.name().toLowerCase().equals(info.name)) {
progressionModel.setMessage(_("tutti.applicationUpdater.startUpdate.jre", info.newVersion));
}
@@ -198,8 +142,6 @@
boolean doRestart = updateJRE || updateTutti || updateI18n || updateHelp;
- updateDoneDb(appToUpdate, appUpdateError);
-
if (doRestart) {
applicationUpdated = true;
@@ -284,6 +226,13 @@
i18nDirectory,
_("tutti.applicationUpdater.updateDone.deleteDirectory.i18n.error", i18nDirectory)
);
+
+ // must remove db cache directory
+ File cacheDirectory = context.getConfig().getServiceConfig().getPersistenceConfig().getCacheDirectory();
+ TuttiIOUtil.forceDeleteOnExit(
+ cacheDirectory,
+ _("tutti.applicationUpdater.updateDone.deleteDirectory.caches.error", i18nDirectory)
+ );
}
}
return doRestart;
@@ -339,56 +288,6 @@
return doRestart;
}
- protected void updateDoneDb(Map<String, ApplicationInfo> appToUpdate,
- Map<String, Exception> appUpdateError) {
- Exception error = getError(UpdateType.DB, appUpdateError);
- if (error != null) {
-
- // something bad while updating db
- if (log.isErrorEnabled()) {
- log.error("Could not update db", error);
- }
- throw new TuttiActionException(action, error);
- } else {
- ApplicationInfo info = getInfo(UpdateType.DB, appToUpdate);
- if (info != null) {
-
- if (log.isInfoEnabled()) {
- log.info(String.format(
- "A db update was downloaded (oldVersion: %s, newVersion: %s), will process it.",
- info.oldVersion, info.newVersion));
- }
-
- // before install or update, regenerate db configuration files
-
- TuttiPersistenceConfig persistenceConfig = regenerateDbConf();
-
- persistenceConfig.generateExternalDbFiles(true);
-
- if (dbInstalled) {
-
- // first database, just copy it to correct directory
-
- prepareFirstDatabase(info);
- } else if (dbUpdated) {
-
- // launch a referential synchronize operation
- synchronizetDatabase(info);
- }
- }
- }
- }
-
- protected TuttiPersistenceConfig regenerateDbConf() {
-
- TuttiPersistenceConfig persistenceConfig =
- context.getConfig().getServiceConfig().getPersistenceConfig();
-
- context.showInformationMessage(
- "Regénérer les fichiers de configuration de la base");
- return persistenceConfig;
- }
-
protected ApplicationInfo getInfo(UpdateType type,
Map<String, ApplicationInfo> appToUpdate) {
return appToUpdate.get(type.name().toLowerCase());
@@ -407,67 +306,4 @@
File result = sources[0];
return result;
}
-
- protected void prepareFirstDatabase(ApplicationInfo info) {
- if (log.isInfoEnabled()) {
- log.info("First time database was downloaded at version: " + info.newVersion);
- }
- File source = getDbDirectory(info);
- File target = context.getConfig().getServiceConfig().getPersistenceConfig().getDbDirectory();
- if (log.isInfoEnabled()) {
- log.info("Copy from " + source + " to " + target);
- }
- try {
- FileUtils.copyDirectory(source, target);
- } catch (IOException e) {
- throw new TuttiTechnicalException(_("tutti.applicationUpdater.prepareFirstDB.copyDirectory.error", source, target), e);
- }
- try {
- FileUtils.deleteDirectory(source.getParentFile());
- } catch (IOException e) {
- throw new TuttiTechnicalException(_("tutti.applicationUpdater.prepareFirstDB.deleteDirectory.error", target), e);
- }
- }
-
- protected void synchronizetDatabase(ApplicationInfo info) {
- if (log.isInfoEnabled()) {
- log.info(String.format("A database update was downloaded (oldVersion: %s, newVersion: %s), will launch a referential synchronize operation ", info.oldVersion, info.newVersion));
- }
- TuttiReferentialSynchronizeService service = context.getTuttiReferentialSynchronizeService();
- ReferentialSynchronizeResult result = new ReferentialSynchronizeResult();
- File dbDirectory = getDbDirectory(info);
-
- TuttiActionUI actionUI = context.getActionUI();
- actionUI.getModel().setProgressionModel(result.getProgressionModel());
- service.prepare(dbDirectory, result);
-
- if (!result.isSuccess()) {
- throw new TuttiTechnicalException(_("tutti.applicationUpdater.synchroDB.prepare.error"), result.getError());
- }
-
- service.synchronize(dbDirectory, result);
-
- if (!result.isSuccess()) {
- throw new TuttiTechnicalException(_("tutti.applicationUpdater.synchroDB.synchro.error"), result.getError());
- }
-
- // reset cache
- if (log.isInfoEnabled()) {
- log.info("Reset all caches.");
- }
- PersistenceService persistence = context.getPersistenceService();
- persistence.clearAllCaches();
-
- // replace the version.appup file content
- File target = context.getConfig().getServiceConfig().getPersistenceConfig().getDbDirectory();
- File versionFile = ApplicationUpdater.getVersionFile(target);
- if (log.isInfoEnabled()) {
- log.info("Replace content of file " + versionFile + " with " + info.newVersion);
- }
- try {
- ApplicationUpdater.storeVersionFile(target, info.newVersion);
- } catch (IOException e) {
- throw new TuttiTechnicalException(_("tutti.applicationUpdater.synchroDB.writeVersion.error", versionFile));
- }
- }
}
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiDbUpdaterCallBack.java (from rev 1217, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiDbUpdaterCallBack.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiDbUpdaterCallBack.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -0,0 +1,273 @@
+package fr.ifremer.tutti.ui.swing;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Maps;
+import fr.ifremer.tutti.TuttiTechnicalException;
+import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.persistence.config.TuttiPersistenceConfig;
+import fr.ifremer.tutti.persistence.service.synchro.ReferentialSynchronizeResult;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.referential.TuttiReferentialSynchronizeService;
+import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
+import fr.ifremer.tutti.ui.swing.util.action.TuttiActionException;
+import fr.ifremer.tutti.ui.swing.util.action.TuttiActionUI;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.updater.ApplicationInfo;
+import org.nuiton.updater.ApplicationUpdater;
+import org.nuiton.updater.ApplicationUpdaterCallback;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * CallBack to update db.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6
+ */
+public class TuttiDbUpdaterCallBack implements ApplicationUpdaterCallback {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(TuttiDbUpdaterCallBack.class);
+
+ public static final String DB_UPDATE_NAME = "db";
+
+ static {
+ n_("tutti.update.db");
+ }
+
+ protected final TuttiUIContext context;
+
+ protected ProgressionModel progressionModel;
+
+ protected boolean dbInstalled;
+
+ protected boolean dbUpdated;
+
+ protected final AbstractTuttiAction action;
+
+ public TuttiDbUpdaterCallBack(AbstractTuttiAction action,
+ ProgressionModel progressionModel) {
+ this.action = action;
+ this.context = action.getContext();
+ this.progressionModel = progressionModel;
+ }
+
+ public boolean isDbUpdated() {
+ return dbUpdated;
+ }
+
+ public boolean isDbInstalled() {
+ return dbInstalled;
+ }
+
+ @Override
+ public Map<String, ApplicationInfo> updateToDo(Map<String, ApplicationInfo> appToUpdate) {
+ Map<String, ApplicationInfo> result = Maps.newHashMap();
+
+ ApplicationInfo info = appToUpdate.get(DB_UPDATE_NAME);
+ if (info == null) {
+ dbInstalled = false;
+ dbUpdated = false;
+ } else {
+ result.put(info.name, info);
+
+ // add auth
+ info.setAuthentication(
+ "t" + "u" + "t" + "t" + "i" + "d" + "b",
+ new char[]{'3', 'R', 'A', 'C', 'e', 'v', '2', 'N', 'w', '8', 'u', 'E', 'D', 'E', 'v', 's', 'y', '0', 'v', 'J'}
+ );
+
+ if (context.isDbExist()) {
+
+ // when db exists always an update
+ dbUpdated = true;
+ } else {
+
+ // when no db, then always install
+ dbInstalled = true;
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public void startUpdate(ApplicationInfo info) {
+
+ if (dbInstalled) {
+ progressionModel.setMessage(_("tutti.applicationUpdater.startUpdate.db.installation", info.newVersion));
+ } else if (dbUpdated) {
+ progressionModel.setMessage(_("tutti.applicationUpdater.startUpdate.db.update", info.newVersion));
+ }
+ }
+
+ @Override
+ public void updateDone(Map<String, ApplicationInfo> appToUpdate,
+ Map<String, Exception> appUpdateError) {
+
+ updateDoneDb(appToUpdate, appUpdateError);
+ }
+
+ @Override
+ public void aborted(String propertiesURL, Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Could not update from " + propertiesURL, eee);
+ }
+ throw TuttiActionException.propagateError(action, eee);
+ }
+
+
+ protected void updateDoneDb(Map<String, ApplicationInfo> appToUpdate,
+ Map<String, Exception> appUpdateError) {
+ Exception error = appUpdateError.get(DB_UPDATE_NAME);
+ if (error != null) {
+
+ // something bad while updating db
+ if (log.isErrorEnabled()) {
+ log.error("Could not update db", error);
+ }
+ throw new TuttiActionException(action, error);
+ } else {
+ ApplicationInfo info = appToUpdate.get(DB_UPDATE_NAME);
+ if (info != null) {
+
+ if (log.isInfoEnabled()) {
+ log.info(String.format(
+ "A db update was downloaded (oldVersion: %s, newVersion: %s), will process it.",
+ info.oldVersion, info.newVersion));
+ }
+
+ // before install or update, regenerate db configuration files
+
+ TuttiPersistenceConfig persistenceConfig = regenerateDbConf();
+
+ persistenceConfig.generateExternalDbFiles(true);
+
+ if (dbInstalled) {
+
+ // first database, just copy it to correct directory
+
+ prepareFirstDatabase(info);
+ } else if (dbUpdated) {
+
+ // launch a referential synchronize operation
+ synchronizetDatabase(info);
+ }
+ }
+ }
+ }
+
+ protected TuttiPersistenceConfig regenerateDbConf() {
+
+ TuttiPersistenceConfig persistenceConfig =
+ context.getConfig().getServiceConfig().getPersistenceConfig();
+
+ context.showInformationMessage(
+ "Regénérer les fichiers de configuration de la base");
+ return persistenceConfig;
+ }
+
+ protected File getDbDirectory(ApplicationInfo info) {
+ File[] sources = info.destDir.listFiles();
+ Preconditions.checkState(
+ sources != null && sources.length == 1,
+ "Downloaded db should contains one directory at " + info.destDir);
+ File result = sources[0];
+ return result;
+ }
+
+ protected void prepareFirstDatabase(ApplicationInfo info) {
+ if (log.isInfoEnabled()) {
+ log.info("First time database was downloaded at version: " + info.newVersion);
+ }
+ File source = getDbDirectory(info);
+ File target = context.getConfig().getServiceConfig().getPersistenceConfig().getDbDirectory();
+ if (log.isInfoEnabled()) {
+ log.info("Copy from " + source + " to " + target);
+ }
+ try {
+ FileUtils.copyDirectory(source, target);
+ } catch (IOException e) {
+ throw new TuttiTechnicalException(_("tutti.applicationUpdater.prepareFirstDB.copyDirectory.error", source, target), e);
+ }
+ try {
+ FileUtils.deleteDirectory(source.getParentFile());
+ } catch (IOException e) {
+ throw new TuttiTechnicalException(_("tutti.applicationUpdater.prepareFirstDB.deleteDirectory.error", target), e);
+ }
+ }
+
+ protected void synchronizetDatabase(ApplicationInfo info) {
+ if (log.isInfoEnabled()) {
+ log.info(String.format("A database update was downloaded (oldVersion: %s, newVersion: %s), will launch a referential synchronize operation ", info.oldVersion, info.newVersion));
+ }
+ TuttiReferentialSynchronizeService service = context.getTuttiReferentialSynchronizeService();
+ ReferentialSynchronizeResult result = new ReferentialSynchronizeResult();
+ File dbDirectory = getDbDirectory(info);
+
+ TuttiActionUI actionUI = context.getActionUI();
+ actionUI.getModel().setProgressionModel(result.getProgressionModel());
+ service.prepare(dbDirectory, result);
+
+ if (!result.isSuccess()) {
+ throw new TuttiTechnicalException(_("tutti.applicationUpdater.synchroDB.prepare.error"), result.getError());
+ }
+
+ service.synchronize(dbDirectory, result);
+
+ if (!result.isSuccess()) {
+ throw new TuttiTechnicalException(_("tutti.applicationUpdater.synchroDB.synchro.error"), result.getError());
+ }
+
+ // reset cache
+ if (log.isInfoEnabled()) {
+ log.info("Reset all caches.");
+ }
+ PersistenceService persistence = context.getPersistenceService();
+ persistence.clearAllCaches();
+
+ // replace the version.appup file content
+ File target = context.getConfig().getServiceConfig().getPersistenceConfig().getDbDirectory();
+ File versionFile = ApplicationUpdater.getVersionFile(target);
+ if (log.isInfoEnabled()) {
+ log.info("Replace content of file " + versionFile + " with " + info.newVersion);
+ }
+ try {
+ ApplicationUpdater.storeVersionFile(target, info.newVersion);
+ } catch (IOException e) {
+ throw new TuttiTechnicalException(_("tutti.applicationUpdater.synchroDB.writeVersion.error", versionFile));
+ }
+ }
+}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -39,6 +39,7 @@
import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUIHandler;
import fr.ifremer.tutti.ui.swing.content.cruise.ValidateCruiseUI;
import fr.ifremer.tutti.ui.swing.content.db.DbManagerUI;
+import fr.ifremer.tutti.ui.swing.content.db.DbManagerUIHandler;
import fr.ifremer.tutti.ui.swing.content.db.OpenDbAction;
import fr.ifremer.tutti.ui.swing.content.home.SelectCruiseUI;
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
@@ -102,6 +103,15 @@
this.persistenceService = null;
}
+ public void reloadDbManagerText() {
+
+ AbstractTuttiUIHandler currentHandler = getCurrentHandler();
+ if (currentHandler instanceof DbManagerUIHandler) {
+ DbManagerUIHandler dbManagerUIHandler = (DbManagerUIHandler) currentHandler;
+ dbManagerUIHandler.updateMessage();
+ }
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@@ -215,6 +225,7 @@
TuttiUIAction<OpenDbAction> uiAction = TuttiActionHelper.createUIAction(this, OpenDbAction.class);
OpenDbAction logicAction = uiAction.getLogicAction();
logicAction.setSkipCheckCurrentScreen(true);
+ logicAction.setUpdateReferentiel(true);
uiAction.actionPerformed(null);
} else {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -28,6 +28,7 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import fr.ifremer.tutti.ui.swing.TuttiApplicationUpdaterCallBack;
+import fr.ifremer.tutti.ui.swing.TuttiDbUpdaterCallBack;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
@@ -184,12 +185,9 @@
protected void addUpdate(Map<String, ApplicationInfo> source,
Map<String, ApplicationInfo> target,
- TuttiApplicationUpdaterCallBack.UpdateType... types) {
- for (TuttiApplicationUpdaterCallBack.UpdateType type : types) {
- String appName = type.name().toLowerCase();
- ApplicationInfo info = source.get(appName);
- target.put(appName, info);
- }
+ String type) {
+ ApplicationInfo info = source.get(type.toLowerCase());
+ target.put(type, info);
}
protected void addUpdateTab(TuttiApplicationConfig config) {
@@ -207,11 +205,14 @@
// create final update map
final Map<String, ApplicationInfo> versions = Maps.newTreeMap();
- addUpdate(applicationVersions, versions,
- UpdateApplicationAction.ALL_APPLICATION_TYPES);
- addUpdate(dbVersions, versions,
- TuttiApplicationUpdaterCallBack.UpdateType.DB);
+ addUpdate(applicationVersions, versions, TuttiApplicationUpdaterCallBack.UpdateType.JRE.name());
+ addUpdate(applicationVersions, versions, TuttiApplicationUpdaterCallBack.UpdateType.TUTTI.name());
+ addUpdate(applicationVersions, versions, TuttiApplicationUpdaterCallBack.UpdateType.I18N.name());
+ addUpdate(applicationVersions, versions, TuttiApplicationUpdaterCallBack.UpdateType.HELP.name());
+
+ addUpdate(dbVersions, versions, TuttiDbUpdaterCallBack.DB_UPDATE_NAME);
+
JScrollPane updatePane = new JScrollPane();
JEditorPane updateArea = new JEditorPane();
updateArea.setContentType("text/html");
@@ -222,12 +223,13 @@
updateArea.setBorder(null);
List<String> params = Lists.newArrayList();
- for (TuttiApplicationUpdaterCallBack.UpdateType type : TuttiApplicationUpdaterCallBack.UpdateType.values()) {
- String appName = type.name().toLowerCase();
- ApplicationInfo info = versions.get(appName);
+ for (Map.Entry<String, ApplicationInfo> entry : versions.entrySet()) {
+ String appName = entry.getKey();
+ ApplicationInfo info = entry.getValue();
String oldVersion = info.oldVersion;
String newVersion = info.newVersion;
- String appLabel = type.getLabel();
+ String i18nKey = "tutti.update." + appName.toLowerCase();
+ String appLabel = _(i18nKey);
if (log.isInfoEnabled()) {
log.info(String.format(
@@ -243,6 +245,7 @@
params.add(_("tutti.about.update.app.up.detail", appLabel, oldVersion, newVersion, appName));
}
}
+
String updateText = _("tutti.about.update.content", urlApplication, urlDb, Joiner.on("\n").join(params));
updateArea.setText(updateText);
updatePane.getViewport().add(updateArea);
@@ -255,33 +258,33 @@
TuttiUIUtil.openLink(url);
} else {
String appType = e.getDescription();
- TuttiApplicationUpdaterCallBack.UpdateType updateType =
- TuttiApplicationUpdaterCallBack.UpdateType.valueOf(appType.toUpperCase());
+
if (log.isInfoEnabled()) {
- log.info("Open url: " + updateType);
+ log.info("Open url: " + appType);
}
AbstractTuttiAction action;
- switch (updateType) {
- case DB: {
- UpdateDbAction logicAction = TuttiActionHelper.createLogicAction(getHandler(), UpdateDbAction.class);
- action = logicAction;
- if (!getContext().isDbExist()) {
+ if (TuttiDbUpdaterCallBack.DB_UPDATE_NAME.equals(appType)) {
+ UpdateDbAction logicAction = TuttiActionHelper.createLogicAction(getHandler(), UpdateDbAction.class);
+ action = logicAction;
+ if (!getContext().isDbExist()) {
- // install db
- action.setActionDescription(
- _("tutti.dbManager.action.installDb.tip"));
- }
+ // install db
+ action.setActionDescription(
+ _("tutti.dbManager.action.installDb.tip"));
}
- break;
- default: {
- UpdateApplicationAction logicAction = TuttiActionHelper.createLogicAction(getHandler(), UpdateApplicationAction.class);
- logicAction.setTypes(updateType);
- logicAction.setActionDescription(_("tutti.main.action.updateSpecificApplication.tip", updateType.getLabel()));
- action = logicAction;
- }
+ } else {
+
+ TuttiApplicationUpdaterCallBack.UpdateType updateType =
+ TuttiApplicationUpdaterCallBack.UpdateType.valueOf(appType.toUpperCase());
+
+ UpdateApplicationAction logicAction = TuttiActionHelper.createLogicAction(getHandler(), UpdateApplicationAction.class);
+ logicAction.setTypes(updateType);
+ logicAction.setActionDescription(_("tutti.main.action.updateSpecificApplication.tip", updateType.getLabel()));
+ action = logicAction;
}
+
// close this dialog
TuttiActionHelper.runAction(about.getClose());
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateApplicationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateApplicationAction.java 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateApplicationAction.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -51,17 +51,10 @@
private static final Log log =
LogFactory.getLog(UpdateApplicationAction.class);
- public static final TuttiApplicationUpdaterCallBack.UpdateType[] ALL_APPLICATION_TYPES = new TuttiApplicationUpdaterCallBack.UpdateType[]{
- TuttiApplicationUpdaterCallBack.UpdateType.JRE,
- TuttiApplicationUpdaterCallBack.UpdateType.I18N,
- TuttiApplicationUpdaterCallBack.UpdateType.TUTTI,
- TuttiApplicationUpdaterCallBack.UpdateType.HELP
- };
-
public UpdateApplicationAction(MainUIHandler handler) {
super(handler, true);
setActionDescription(_("tutti.main.action.updateApplication.tip"));
- types = ALL_APPLICATION_TYPES;
+ types = TuttiApplicationUpdaterCallBack.UpdateType.values();
}
protected TuttiApplicationUpdaterCallBack.UpdateType[] types;
@@ -76,18 +69,6 @@
// check application url is reachable
TuttiUIContext context = getContext();
doAction = context.checkUpdateApplicationReachable();
-// TuttiApplicationConfig config = context.getConfig();
-// String url = config.getUpdateApplicationUrl();
-//
-// try {
-// TuttiUIUtil.tryToConnectToUpdateUrl(
-// url,
-// n_("tutti.error.update.could.not.reach.url")
-// );
-// } catch (TuttiBusinessException e) {
-// TuttiUIContext.getErrorHelper().showWarningDialog(e.getMessage());
-// doAction = false;
-// }
}
return doAction;
}
@@ -95,7 +76,7 @@
@Override
public void releaseAction() {
super.releaseAction();
- types = ALL_APPLICATION_TYPES;
+ types = TuttiApplicationUpdaterCallBack.UpdateType.values();
}
@Override
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateDbAction.java 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateDbAction.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -25,16 +25,18 @@
*/
import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.ui.swing.TuttiApplicationUpdaterCallBack;
+import fr.ifremer.tutti.ui.swing.TuttiDbUpdaterCallBack;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig;
-import fr.ifremer.tutti.ui.swing.content.db.OpenDbAction;
-import fr.ifremer.tutti.ui.swing.util.action.TuttiActionHelper;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.updater.ApplicationInfo;
import org.nuiton.updater.ApplicationUpdater;
+import javax.swing.JOptionPane;
import java.io.File;
+import java.util.Map;
import static org.nuiton.i18n.I18n._;
@@ -50,6 +52,8 @@
private static final Log log =
LogFactory.getLog(UpdateDbAction.class);
+ protected ApplicationInfo updateDbVersion;
+
public UpdateDbAction(MainUIHandler handler) {
super(handler, true);
setActionDescription(_("tutti.dbManager.action.upgradeDb.tip"));
@@ -59,24 +63,42 @@
public boolean prepareAction() throws Exception {
boolean doAction = super.prepareAction();
+ updateDbVersion = null;
+
if (doAction) {
// check db url is reachable
- TuttiUIContext context = getContext();
- doAction = context.checkUpdateDbReachable();
-// TuttiApplicationConfig config = context.getConfig();
-// String url = config.getUpdateDbUrl();
-//
-// try {
-// TuttiUIUtil.tryToConnectToUpdateUrl(
-// url,
-// n_("tutti.error.update.could.not.reach.url")
-// );
-// } catch (TuttiBusinessException e) {
-// TuttiUIContext.getErrorHelper().showWarningDialog(e.getMessage());
-// doAction = false;
-// }
+ doAction = getContext().checkUpdateDbReachable();
}
+ if (doAction) {
+
+ // get the next db version
+ ApplicationUpdater up = new ApplicationUpdater();
+
+ // get db updates
+ Map<String, ApplicationInfo> dbVersions =
+ up.getVersions(getConfig().getUpdateDbUrl(),
+ getConfig().getDataDirectory());
+ updateDbVersion =
+ dbVersions.get(TuttiDbUpdaterCallBack.DB_UPDATE_NAME);
+
+ if (updateDbVersion != null) {
+
+ // ask user if it wants to do the update
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ _("tutti.dbManager.updatedb.found", updateDbVersion.newVersion),
+ _("tutti.common.askBeforeUpdate.help"));
+ int i = JOptionPane.showConfirmDialog(
+ getHandler().getUI(),
+ htmlMessage,
+ _("tutti.dbManager.title.confirm.updatedb"),
+ JOptionPane.OK_CANCEL_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
+
+ doAction = i == JOptionPane.OK_OPTION;
+ }
+ }
return doAction;
}
@@ -96,10 +118,10 @@
ProgressionModel progressionModel = new ProgressionModel();
context.getActionUI().getModel().setProgressionModel(progressionModel);
progressionModel.setMessage(_("tutti.dbManager.action.upgradeDb.check"));
- TuttiApplicationUpdaterCallBack callback =
- new TuttiApplicationUpdaterCallBack(this, progressionModel);
- callback.setTypes(TuttiApplicationUpdaterCallBack.UpdateType.DB);
+ TuttiDbUpdaterCallBack callback =
+ new TuttiDbUpdaterCallBack(this, progressionModel);
ApplicationUpdater up = new ApplicationUpdater();
+
up.update(url,
current,
dest,
@@ -107,24 +129,24 @@
callback,
progressionModel);
- if (callback.isDbInstalled()) {
+ if (callback.isDbUpdated()) {
- progressionModel.setMessage(_("tutti.dbManager.action.upgradeDb.opening"));
+ sendMessage(_("tutti.dbManager.action.upgradeDb.done", updateDbVersion.newVersion));
- getContext().setDbExist(true);
-
- // open db
- TuttiActionHelper.runInternalAction(getHandler(), OpenDbAction.class);
-
- } else if (callback.isDbUpdated()) {
-
- progressionModel.setMessage(_("tutti.dbManager.action.upgradeDb.reloading"));
-
- // open db
- TuttiActionHelper.runInternalAction(getHandler(), OpenDbAction.class);
-
} else {
sendMessage(_("tutti.dbManager.action.upgradeDb.upToDate"));
}
}
+
+ @Override
+ public void postSuccessAction() {
+ handler.reloadDbManagerText();
+ super.postSuccessAction();
+ }
+
+ @Override
+ public void postFailedAction(Throwable error) {
+ handler.reloadDbManagerText();
+ super.postFailedAction(error);
+ }
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -74,9 +74,6 @@
// clean db context
getContext().clearDbContext();
-
- // Close the application, will exit and restart application
- //RunTutti.closeTutti(getHandler(), RunTutti.DELETE_DB_EXIT_CODE);
}
@Override
@@ -86,7 +83,13 @@
sendMessage(_("tutti.flash.info.db.closed", jdbcUrl));
// make sure title is reloaded
- getUI().getHandler().changeTitle();
+ handler.reloadDbManagerText();
+ handler.changeTitle();
}
+ @Override
+ public void postFailedAction(Throwable error) {
+ handler.reloadDbManagerText();
+ super.postFailedAction(error);
+ }
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.css 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.css 2013-09-25 13:31:19 UTC (rev 1223)
@@ -36,7 +36,6 @@
focusable:false;
contentType: "text/html";
border: {new EmptyBorder(5, 5, 5, 5)};
- text: {handler.updateMessage(model.isDbExist(), model.isDbLoaded())};
}
#installOrReinstallDbButton {
@@ -67,16 +66,6 @@
_help: {"tutti.dbManager.action.openDb.help"};
}
-/*#closeDbButton {
- actionIcon: close-db;
- text: "tutti.dbManager.action.closeDb";
- i18nMnemonic: "tutti.dbManager.action.closeDb.mnemonic";
- visible: {model.isDbLoaded()};
- _tuttiAction: {CloseDbAction.class};
- toolTipText: "tutti.dbManager.action.closeDb.tip";
- _help: {"tutti.dbManager.action.closeDb.help"};
-}*/
-
#upgradeDbButton {
actionIcon: update-referential;
text: "tutti.dbManager.action.upgradeDb";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUIHandler.java 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUIHandler.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -24,18 +24,27 @@
* #L%
*/
+import com.google.common.collect.Maps;
+import fr.ifremer.tutti.ui.swing.TuttiDbUpdaterCallBack;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.updater.ApplicationInfo;
+import org.nuiton.updater.ApplicationUpdater;
import org.nuiton.util.Version;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.Map;
import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
/**
* @author tchemit <chemit(a)codelutin.com>
@@ -43,6 +52,9 @@
*/
public class DbManagerUIHandler extends AbstractTuttiUIHandler<TuttiUIContext, DbManagerUI> {
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(DbManagerUIHandler.class);
+
public DbManagerUIHandler(TuttiUIContext context, DbManagerUI ui) {
super(context, ui);
}
@@ -51,32 +63,84 @@
public void beforeInitUI() {
}
- public String updateMessage(boolean dbExist, boolean dbLoaded) {
+ public void updateMessage() {
+
+ boolean dbExist = getContext().isDbExist();
+ boolean dbLoaded = getContext().isDbLoaded();
+
+
+ if (log.isInfoEnabled()) {
+ log.info("Rebuild information text... (dbExist?" + dbExist +
+ "/ dbLoaded?" + dbLoaded + ")");
+ }
+
String message;
if (dbExist) {
- String jdbcUrl = getConfig().getServiceConfig().getPersistenceConfig().getJdbcUrl();
+ TuttiApplicationConfig config = getConfig();
+ String jdbcUrl = config.getServiceConfig().getPersistenceConfig().getJdbcUrl();
+
+ Map<String, String> caracteristics = Maps.newLinkedHashMap();
+
+ String title;
+
+ caracteristics.put(_("tutti.dbManager.caracteristic.url"), jdbcUrl);
+
if (dbLoaded) {
Version dbVersion = getContext().getPersistenceService().getDbVersion();
// db loaded
- message = _("tutti.dbManager.info.db.loaded", jdbcUrl, dbVersion);
+ title = n_("tutti.dbManager.info.db.loaded");
+ caracteristics.put(_("tutti.dbManager.caracteristic.schemaVersion"), dbVersion.toString());
+
} else {
// no db loaded
- message = _("tutti.dbManager.info.no.db.loaded", jdbcUrl);
+ title = n_("tutti.dbManager.info.no.db.loaded");
}
+
+ // get referential version
+
+ if (getContext().checkUpdateDbReachable()) {
+ String urlDb = config.getUpdateDbUrl();
+
+ ApplicationUpdater up = new ApplicationUpdater();
+ Map<String, ApplicationInfo> dbVersions = up.getVersions(urlDb, config.getDataDirectory());
+
+ ApplicationInfo updateDbVersion =
+ dbVersions.get(TuttiDbUpdaterCallBack.DB_UPDATE_NAME);
+
+ String currentReferentialVersion = updateDbVersion.oldVersion;
+ String newReferentialVersion = updateDbVersion.newVersion;
+ caracteristics.put(_("tutti.dbManager.caracteristic.referentialVersion"), currentReferentialVersion);
+ if (newReferentialVersion != null) {
+ caracteristics.put(_("tutti.dbManager.caracteristic.lastReferentialVersion"), newReferentialVersion);
+ }
+ }
+
+ StringBuilder caracteristicsToString = new StringBuilder("<ul>");
+ for (Map.Entry<String, String> entry : caracteristics.entrySet()) {
+ caracteristicsToString.append("<li>");
+ caracteristicsToString.append(entry.getKey());
+ caracteristicsToString.append(" : <strong>");
+ caracteristicsToString.append(entry.getValue());
+ caracteristicsToString.append("</strong></li>");
+ }
+ caracteristicsToString.append("</ul>");
+
+ message = _(title, caracteristicsToString);
+
} else {
// db does not exist
message = _("tutti.dbManager.info.no.db.exist");
-// ui.getInformationLabel().setText(_(message));
}
- return "<html><body>" + message + "</body></html>";
+ String result = "<html><body>" + message + "</body></html>";
+ getUI().getInformationArea().setText(result);
}
@Override
@@ -102,6 +166,8 @@
}
});
+ updateMessage();
+
SwingUtilities.invokeLater(
new Runnable() {
@Override
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -281,14 +281,6 @@
getHandler().getPersistenceService().updateSchema();
sendMessage(_("tutti.flash.info.db.schema.updated", dbVersion, applicationVersion));
-
- // reload a special databinding (dbLoaded)
- AbstractTuttiUIHandler currentHandler = getHandler().getCurrentHandler();
- if (currentHandler instanceof DbManagerUIHandler) {
- DbManagerUIHandler dbManagerUIHandler = (DbManagerUIHandler) currentHandler;
- dbManagerUIHandler.getUI().applyDataBinding(DbManagerUI.BINDING_INFORMATION_AREA_TEXT);
-
- }
}
// ------------------------------------------------------------------ //
@@ -308,6 +300,8 @@
@Override
public void postSuccessAction() {
+ handler.reloadDbManagerText();
+
super.postSuccessAction();
if (closeDb) {
@@ -319,4 +313,11 @@
// make sure title is reloaded
getUI().getHandler().changeTitle();
}
+
+ @Override
+ public void postFailedAction(Throwable error) {
+ handler.reloadDbManagerText();
+ super.postFailedAction(error);
+ }
+
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/InstallDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/InstallDbAction.java 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/InstallDbAction.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -26,7 +26,7 @@
import com.google.common.base.Preconditions;
import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.ui.swing.TuttiApplicationUpdaterCallBack;
+import fr.ifremer.tutti.ui.swing.TuttiDbUpdaterCallBack;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig;
import fr.ifremer.tutti.ui.swing.content.AbstractMainUITuttiAction;
@@ -70,21 +70,7 @@
if (doAction) {
// check db url is reachable
- TuttiUIContext context = getContext();
- doAction = context.checkUpdateDbReachable();
-
-// TuttiApplicationConfig config = context.getConfig();
-// String url = config.getUpdateDbUrl();
-//
-// try {
-// TuttiUIUtil.tryToConnectToUpdateUrl(
-// url,
-// n_("tutti.error.update.could.not.reach.url")
-// );
-// } catch (TuttiBusinessException e) {
-// TuttiUIContext.getErrorHelper().showWarningDialog(e.getMessage());
-// doAction = false;
-// }
+ doAction = getContext().checkUpdateDbReachable();
}
if (doAction) {
@@ -118,9 +104,8 @@
File dest = new File(config.getTuttiBasedir(), "NEW");
progressionModel.increments(_("tutti.dbManager.action.upgradeDb.check"));
- TuttiApplicationUpdaterCallBack callback =
- new TuttiApplicationUpdaterCallBack(this, progressionModel);
- callback.setTypes(TuttiApplicationUpdaterCallBack.UpdateType.DB);
+ TuttiDbUpdaterCallBack callback =
+ new TuttiDbUpdaterCallBack(this, progressionModel);
ApplicationUpdater up = new ApplicationUpdater();
up.update(url,
current,
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -28,7 +28,9 @@
import fr.ifremer.tutti.persistence.ProgressionModel;
import fr.ifremer.tutti.persistence.TuttiPersistence;
import fr.ifremer.tutti.persistence.config.TuttiPersistenceConfig;
+import fr.ifremer.tutti.ui.swing.TuttiDbUpdaterCallBack;
import fr.ifremer.tutti.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig;
import fr.ifremer.tutti.ui.swing.content.AbstractChangeScreenAction;
import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
@@ -36,11 +38,14 @@
import fr.ifremer.tutti.ui.swing.util.action.TuttiUIAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.updater.ApplicationInfo;
+import org.nuiton.updater.ApplicationUpdater;
import org.nuiton.util.Version;
import javax.swing.JOptionPane;
import java.io.File;
import java.util.Date;
+import java.util.Map;
import static org.nuiton.i18n.I18n._;
@@ -63,15 +68,23 @@
protected boolean updateSchema;
+ protected boolean updateReferentiel;
+
protected boolean closeDb;
protected String jdbcUrl;
+ protected ApplicationInfo updateDbVersion;
+
public OpenDbAction(MainUIHandler handler) {
super(handler, true, TuttiScreen.SELECT_CRUISE);
setActionDescription(_("tutti.dbManager.action.openDb.tip"));
}
+ public void setUpdateReferentiel(boolean updateReferentiel) {
+ this.updateReferentiel = updateReferentiel;
+ }
+
@Override
public boolean prepareAction() throws Exception {
@@ -81,6 +94,40 @@
dbVersion = applicationVersion = null;
file = null;
closeDb = updateSchema = false;
+ updateDbVersion = null;
+
+ updateReferentiel &= getContext().checkUpdateDbReachable();
+
+ if (updateReferentiel) {
+
+ // get the next db version
+ ApplicationUpdater up = new ApplicationUpdater();
+
+ // get db updates
+ Map<String, ApplicationInfo> dbVersions =
+ up.getVersions(getConfig().getUpdateDbUrl(),
+ getConfig().getDataDirectory());
+ updateDbVersion =
+ dbVersions.get(TuttiDbUpdaterCallBack.DB_UPDATE_NAME);
+
+ if (updateDbVersion != null) {
+
+ // ask user if it wants to do the update
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ _("tutti.dbManager.updatedb.found", updateDbVersion.newVersion),
+ _("tutti.common.askBeforeUpdate.help"));
+ int i = JOptionPane.showConfirmDialog(
+ getHandler().getTopestUI(),
+ htmlMessage,
+ _("tutti.dbManager.title.confirm.updatedb"),
+ JOptionPane.OK_CANCEL_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
+
+ updateReferentiel = i == JOptionPane.OK_OPTION;
+ }
+
+ }
}
return canContinue;
}
@@ -97,7 +144,7 @@
// at the beginning 3 steps (open db + check version + check db context)
ProgressionModel progressionModel = new ProgressionModel();
setProgressionModel(progressionModel);
- progressionModel.setTotal(3);
+ progressionModel.setTotal(3 + (updateReferentiel ? 1 : 0));
// ------------------------------------------------------------------ //
// --- open db //
@@ -140,6 +187,7 @@
log.info("Detected schema application version:" + applicationVersion);
}
+ TuttiApplicationConfig config = getConfig();
if (dbVersion.equals(applicationVersion)) {
// database schema is up to date
@@ -172,7 +220,7 @@
// ask user file where to backup db
file = saveFile(
- getConfig().getServiceConfig().getPersistenceConfig().getDbBackupDirectory(),
+ config.getServiceConfig().getPersistenceConfig().getDbBackupDirectory(),
"tutti-db-" + ExportDbAction.df.format(new Date()),
"zip",
_("tutti.dbManager.title.choose.dbBackupFile"),
@@ -249,6 +297,39 @@
getHandler().getPersistenceService().updateSchema();
}
+ if (updateReferentiel) {
+
+ // ------------------------------------------------------------------ //
+ // --- update referentiel //
+ // ------------------------------------------------------------------ //
+
+ progressionModel.increments(_("tutti.openDb.step.updateReferential"));
+
+ File current = config.getDataDirectory();
+ String url = config.getUpdateDbUrl();
+
+ File dest = new File(config.getTuttiBasedir(), "NEW");
+
+ progressionModel.setMessage(_("tutti.dbManager.action.upgradeDb.check"));
+ TuttiDbUpdaterCallBack callback =
+ new TuttiDbUpdaterCallBack(this, progressionModel);
+ ApplicationUpdater up = new ApplicationUpdater();
+ up.update(url,
+ current,
+ dest,
+ false,
+ callback,
+ progressionModel);
+
+ if (callback.isDbUpdated()) {
+
+ progressionModel.setMessage(_("tutti.dbManager.action.upgradeDb.reloading"));
+
+ } else {
+ sendMessage(_("tutti.dbManager.action.upgradeDb.upToDate"));
+ }
+ }
+
// ------------------------------------------------------------------ //
// --- check db context //
// ------------------------------------------------------------------ //
@@ -269,8 +350,10 @@
@Override
public void postSuccessAction() {
+ handler.reloadDbManagerText();
+
// make sure title is reloaded
- getUI().getHandler().changeTitle();
+ handler.changeTitle();
if (closeDb) {
sendMessage(_("tutti.flash.info.db.not.opened", jdbcUrl));
@@ -284,4 +367,12 @@
sendMessage(_("tutti.flash.info.db.opened", jdbcUrl));
}
}
+
+ @Override
+ public void postFailedAction(Throwable error) {
+
+ handler.reloadDbManagerText();
+
+ super.postFailedAction(error);
+ }
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-09-25 13:31:19 UTC (rev 1223)
@@ -25,6 +25,7 @@
tutti.applicationUpdater.synchroDB.prepare.error=
tutti.applicationUpdater.synchroDB.synchro.error=
tutti.applicationUpdater.synchroDB.writeVersion.error=
+tutti.applicationUpdater.updateDone.deleteDirectory.caches.error=
tutti.applicationUpdater.updateDone.deleteDirectory.dbConf.error=
tutti.applicationUpdater.updateDone.deleteDirectory.enum.error=
tutti.applicationUpdater.updateDone.deleteDirectory.i18n.error=
@@ -63,6 +64,7 @@
tutti.common.askBeforeEditProtocol.help=
tutti.common.askBeforeEditProtocol.title=
tutti.common.askBeforeImportProtocol.help=
+tutti.common.askBeforeUpdate.help=
tutti.common.askCancelEditBeforeLeaving.help=
tutti.common.askCancelEditBeforeLeaving.title=
tutti.common.askOverwriteFile.help=
@@ -294,6 +296,7 @@
tutti.dbManager.action.reinstallDb.tip=
tutti.dbManager.action.upgradeDb=
tutti.dbManager.action.upgradeDb.check=
+tutti.dbManager.action.upgradeDb.done=
tutti.dbManager.action.upgradeDb.mnemonic=
tutti.dbManager.action.upgradeDb.no.backup.db.choosen=
tutti.dbManager.action.upgradeDb.opening=
@@ -306,6 +309,10 @@
tutti.dbManager.action.upgradeDb.schema.version.not.found=
tutti.dbManager.action.upgradeDb.tip=
tutti.dbManager.action.upgradeDb.upToDate=
+tutti.dbManager.caracteristic.lastReferentialVersion=
+tutti.dbManager.caracteristic.referentialVersion=
+tutti.dbManager.caracteristic.schemaVersion=
+tutti.dbManager.caracteristic.url=
tutti.dbManager.info.db.loaded=
tutti.dbManager.info.no.db.exist=
tutti.dbManager.info.no.db.loaded=
@@ -313,7 +320,9 @@
tutti.dbManager.title.choose.dbBackupFile=
tutti.dbManager.title.choose.dbExportFile=
tutti.dbManager.title.choose.dbImportFile=
+tutti.dbManager.title.confirm.updatedb=
tutti.dbManager.title.schema.toupdate=
+tutti.dbManager.updatedb.found=
tutti.editAccidentalBatch.action.createBatch=
tutti.editAccidentalBatch.action.createBatch.mnemonic=
tutti.editAccidentalBatch.action.createBatch.tip=
@@ -922,6 +931,7 @@
tutti.editSpeciesBatch.action.splitBatch=
tutti.editSpeciesBatch.action.splitBatch.mnemonic=
tutti.editSpeciesBatch.action.splitBatch.tip=
+tutti.editSpeciesBatch.error.sampleCategoryValue.notAvailable=
tutti.editSpeciesBatch.field.speciesTotalInertWeight=
tutti.editSpeciesBatch.field.speciesTotalInertWeight.tip=
tutti.editSpeciesBatch.field.speciesTotalLivingNotItemizedWeight=
@@ -951,6 +961,7 @@
tutti.editSpeciesBatch.table.header.species=
tutti.editSpeciesBatch.table.header.toConfirm=
tutti.editSpeciesBatch.table.header.weight=
+tutti.editSpeciesBatch.title.changeSampleCategoryValue=
tutti.editSpeciesFrequencies.action.cancel=
tutti.editSpeciesFrequencies.action.cancel.mnemonic=
tutti.editSpeciesFrequencies.action.cancel.tip=
@@ -1239,6 +1250,7 @@
tutti.openDb.step.check.dbContext=
tutti.openDb.step.checkSchemaVersion=
tutti.openDb.step.open=
+tutti.openDb.step.updateReferential=
tutti.openDb.step.will.migrateSchema=
tutti.option.cancel=
tutti.option.cleanAndClone=
@@ -1353,6 +1365,7 @@
tutti.splitSpeciesBatch.table.header.weight=
tutti.splitSpeciesBatch.title=
tutti.timeeditor.H=
+tutti.update.=
tutti.update.db=
tutti.update.help=
tutti.update.i18n=
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-09-25 13:31:19 UTC (rev 1223)
@@ -25,6 +25,7 @@
tutti.applicationUpdater.synchroDB.prepare.error=Erreur lors de la préparation de la synchronisation de la base
tutti.applicationUpdater.synchroDB.synchro.error=Erreur lors de la synchronisation de la base
tutti.applicationUpdater.synchroDB.writeVersion.error=Erreur lors de l'écriture de la nouvelle version de la base de données dans le fichier %s
+tutti.applicationUpdater.updateDone.deleteDirectory.caches.error=Erreur lors de la suppression du dossier des caches
tutti.applicationUpdater.updateDone.deleteDirectory.dbConf.error=Erreur lors de la suppression du dossier de configuration de base de données
tutti.applicationUpdater.updateDone.deleteDirectory.enum.error=Erreur lors de la suppression du dossier d'énumération
tutti.applicationUpdater.updateDone.deleteDirectory.i18n.error=Erreur lors de la suppression du dossier d'internationalisation
@@ -63,6 +64,7 @@
tutti.common.askBeforeEditProtocol.help=Que voulez-vous faire?<ul><li><strong>Annuler</strong> pour ne pas éditer le protocole</li><li><strong>Éditer</strong> pour éditer le protocole en conservant les catégories non connues (elle ne seront pas affichées)</li><li><strong>Nettoyer et Éditer</strong> pour supprimer les catégories non compatibles et éditer le protocole</li></ul>
tutti.common.askBeforeEditProtocol.title=Catégories non compatibles détectées dans le protocole
tutti.common.askBeforeImportProtocol.help=Que voulez-vous faire?<ul><li><strong>Annuler</strong> pour ne pas importer le protocole</li><li><strong>Importer</strong> pour importer le protocole en conservant les catégories non connues (elle ne seront pas affichées)</li><li><strong>Nettoyer et Importer</strong> pour supprimer les catégories non compatibles dans le protocole importé</li></ul>
+tutti.common.askBeforeUpdate.help=Que voulez-vous faire ?<ul><li><strong>Annuler</strong> pour ne pas effectuer la mise à jour</li><li><strong>OK</strong> pour lancer la mise à jour</li></ul>
tutti.common.askCancelEditBeforeLeaving.help=Que voulez-vous faire ?<ul><li><strong>Annuler</strong> pour rester sur cet écran</li><li><strong>OK</strong> pour quitter l'écran en abandonnant les modifications</li></ul>
tutti.common.askCancelEditBeforeLeaving.title=Modifications non enregistrées mais invalides
tutti.common.askOverwriteFile.help=Que voulez-vous faire ?<ul><li><strong>Annuler</strong> pour ne pas écraser le fichier et annuler l'opération</li><li><strong>Oui</strong> pour écraser le fichier et continuer l'opération</li></ul>
@@ -293,6 +295,7 @@
tutti.dbManager.action.reinstallDb.tip=Télécharger puis ré-installer la base de données
tutti.dbManager.action.upgradeDb=Mettre à jour les référentiels
tutti.dbManager.action.upgradeDb.check=Recherche des mises à jour de la base
+tutti.dbManager.action.upgradeDb.done=La mise à jour des référentiel en version <strong>%s</strong> est terminée.
tutti.dbManager.action.upgradeDb.mnemonic=V
tutti.dbManager.action.upgradeDb.no.backup.db.choosen=La base ne sera pas migrée (vous avez annulé la sauvegarde avant migration).
tutti.dbManager.action.upgradeDb.opening=Ouverture de la base de données
@@ -304,15 +307,21 @@
tutti.dbManager.action.upgradeDb.schema.too.high.help=Souhaitez-vous poursuivre l'import de la base de données ?<ul><li><strong>Oui</strong> pour charger la base en version plus récente</li><li><strong>Annuler</strong> pour ne pas charger la base</li></ul>
tutti.dbManager.action.upgradeDb.schema.version.not.found=L'application n'a pas pu déterminer la version de la base de données à importer. L'import ne peut pas être réalisé, veuillez contacter les administrateurs de l'application.
tutti.dbManager.action.upgradeDb.tip=Mettre à jour les référentiels
-tutti.dbManager.action.upgradeDb.upToDate=Aucune mise à jour de base détectée
-tutti.dbManager.info.db.loaded=Tutti est connecté à une base de données<hr/>Caractéristiques de cette base \:<ul><li>Url de connexion \: <strong>%s</strong></li><li>Version\: <strong>%s</strong></li></ul>
+tutti.dbManager.action.upgradeDb.upToDate=<strong>Aucune mise à jour de base détectée</strong>
+tutti.dbManager.caracteristic.lastReferentialVersion=Version du référentiel disponible en mis à jour
+tutti.dbManager.caracteristic.referentialVersion=Version du référentiel utilisé
+tutti.dbManager.caracteristic.schemaVersion=Version du schema
+tutti.dbManager.caracteristic.url=Url de connexion
+tutti.dbManager.info.db.loaded=Tutti est connecté à une base de données<hr/>Caractéristiques de cette base \: %s
tutti.dbManager.info.no.db.exist=Aucune base détectée.<hr/>Vous pouvez installer la dernière disponible sur le réseau via l'action <strong>installer</strong>; ou bien en importer une via l'action <strong>importer</strong>.
-tutti.dbManager.info.no.db.loaded=Une base a été détectée (<strong>%s</strong>).<hr/>La base n'est pas ouverte, vous pouvez l'ouvrir via l'action <strong>Ouvrir</strong>.<br/>Si l'ouverture ne fonctionne pas; veuillez bien prendre soin de quitter les applications qui pourraient utiliser cette base.
+tutti.dbManager.info.no.db.loaded=Une base a été détectée.<hr/>La base n'est pas ouverte, vous pouvez l'ouvrir via l'action <strong>Ouvrir</strong>.<br/>Si l'ouverture ne fonctionne pas; veuillez bien prendre soin de quitter les applications qui pourraient utiliser cette base.<br/>Caractéristiques de cette base \: %s
tutti.dbManager.title.backup.db=Sauvegarde de la base
tutti.dbManager.title.choose.dbBackupFile=Sauvegarder la base de données
tutti.dbManager.title.choose.dbExportFile=Exporter la base de données
tutti.dbManager.title.choose.dbImportFile=Importer la base de données
+tutti.dbManager.title.confirm.updatedb=Confirmer la mise à jour des réferentiels
tutti.dbManager.title.schema.toupdate=Mise à jour de la base détéctée
+tutti.dbManager.updatedb.found=Une mise à jour des référentiels (version <strong>%s</strong>) est disponible.
tutti.editAccidentalBatch.action.createBatch=Créer une capture accidentelle
tutti.editAccidentalBatch.action.createBatch.mnemonic=C
tutti.editAccidentalBatch.action.createBatch.tip=Créer une capture accidentelle
@@ -392,7 +401,6 @@
tutti.editBenthosBatch.action.splitBatch.mnemonic=C
tutti.editBenthosBatch.action.splitBatch.tip=Catégoriser le lot courant (celui de la ligne sélectionné)
tutti.editBenthosBatch.error.sampleCategoryValue.notAvailable=La valeur %s de la catégorie %s est déjà utilisée
-tutti.editSpeciesBatch.error.sampleCategoryValue.notAvailable=La valeur %s de la catégorie %s est déjà utilisée
tutti.editBenthosBatch.field.benthosTotalInertWeight=Poids inerte trié
tutti.editBenthosBatch.field.benthosTotalInertWeight.tip=Poids de la fraction inerte restante après le tri du benthos (cailloux, vase, débris coquilliers, etc.)
tutti.editBenthosBatch.field.benthosTotalLivingNotItemizedWeight=Poids vivant non détaillé trié
@@ -429,7 +437,6 @@
tutti.editBenthosBatch.table.header.weight=Poids sous-échantillonné
tutti.editBenthosBatch.table.header.weight.tip=Poids du lot mesuré ou dénombré
tutti.editBenthosBatch.title.changeSampleCategoryValue=Changer la valeur de la catégorie %s
-tutti.editSpeciesBatch.title.changeSampleCategoryValue=Changer la valeur de la catégorie %s
tutti.editBenthosFrequencies.action.cancel=Annuler
tutti.editBenthosFrequencies.action.cancel.mnemonic=A
tutti.editBenthosFrequencies.action.cancel.tip=Annuler l'édition des mensurations
@@ -925,6 +932,7 @@
tutti.editSpeciesBatch.action.splitBatch=Catégoriser le lot
tutti.editSpeciesBatch.action.splitBatch.mnemonic=C
tutti.editSpeciesBatch.action.splitBatch.tip=Catégoriser le lot courant (celui de la ligne sélectionné)
+tutti.editSpeciesBatch.error.sampleCategoryValue.notAvailable=La valeur %s de la catégorie %s est déjà utilisée
tutti.editSpeciesBatch.field.speciesTotalInertWeight=Poids inerte trié
tutti.editSpeciesBatch.field.speciesTotalInertWeight.tip=Poids de la fraction inerte restante après le tri des espèces (cailloux, vase, débris coquilliers, etc.)
tutti.editSpeciesBatch.field.speciesTotalLivingNotItemizedWeight=Poids vivant non détaillé trié
@@ -954,6 +962,7 @@
tutti.editSpeciesBatch.table.header.species=Espèce
tutti.editSpeciesBatch.table.header.toConfirm=A Confirmer
tutti.editSpeciesBatch.table.header.weight=Poids sous-échantillonné
+tutti.editSpeciesBatch.title.changeSampleCategoryValue=Changer la valeur de la catégorie %s
tutti.editSpeciesFrequencies.action.cancel=Annuler
tutti.editSpeciesFrequencies.action.cancel.mnemonic=A
tutti.editSpeciesFrequencies.action.cancel.tip=Annuler l'édition des mensurations
@@ -1079,6 +1088,7 @@
tutti.importDb.step.closeDb=Fermeture de la base
tutti.importDb.step.openDb=Ouverture de la base de données <strong>%s</strong>
tutti.importDb.step.unzipArchive=Décompression de l'archive
+tutti.importDb.step.updateReferential=Mise à jour des référentiels
tutti.importDb.step.will.migrateSchema=Démarrage de la mise à jour du schéma de la base depuis la version %s vers la version %s
tutti.importProtocol.action.success=Protocole [%s] lu depuis le fichier.
tutti.importPupitri.carrouselFile.extension=car
@@ -1243,6 +1253,7 @@
tutti.openDb.step.check.dbContext=Vérification du context de saisie
tutti.openDb.step.checkSchemaVersion=Vérification de la compatibilité de la base
tutti.openDb.step.open=Ouverture de la base <strong>%s</strong>
+tutti.openDb.step.updateReferential=
tutti.openDb.step.will.migrateSchema=Démarrage de la mise à jour du schéma de la base depuis la version %s vers la version %s
tutti.option.cancel=Annuler
tutti.option.cleanAndClone=Nettoyer et Cloner
1
0
r1222 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches: benthos species
by tchemit@users.forge.codelutin.com 25 Sep '13
by tchemit@users.forge.codelutin.com 25 Sep '13
25 Sep '13
Author: tchemit
Date: 2013-09-25 12:48:17 +0200 (Wed, 25 Sep 2013)
New Revision: 1222
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1222
Log:
refs #3315: [CAPTURE] pouvoir modifier la valeur de la cat?\195?\169gorisation d'un lot (fix auto save)
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-09-25 07:22:58 UTC (rev 1221)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-09-25 10:48:17 UTC (rev 1222)
@@ -474,6 +474,12 @@
//-- Other properties --//
//------------------------------------------------------------------------//
+ public BenthosBatchRowModel getFirstAncestor(Integer sampleCategoryId) {
+ SampleCategory<?> sampleCategory = getSampleCategoryById(sampleCategoryId);
+ BenthosBatchRowModel firstAncestor = getFirstAncestor(sampleCategory);
+ return firstAncestor;
+ }
+
@Override
public boolean isSpeciesToConfirm() {
return speciesToConfirm;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-09-25 07:22:58 UTC (rev 1221)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-09-25 10:48:17 UTC (rev 1222)
@@ -265,30 +265,25 @@
}
/**
- * Update the sample category value of all childs of the given {@code row}.
+ * Update the sample category value of the given {@code row}.
*
- * @param row the row to walk through
+ * @param row the row to walk through
* @param columnIndex index of the column where the sample category is
* @param newValue new sample category value to set
* @since 2.6
*/
public void updateSampleCategorieValue(BenthosBatchRowModel row,
- int sampleCategoryId,
int columnIndex,
Serializable newValue) {
SampleCategoryColumnIdentifier<BenthosBatchRowModel> identifier =
(SampleCategoryColumnIdentifier<BenthosBatchRowModel>) getIdentifier(columnIndex);
- // get the first ancestor using the category to update
- SampleCategory<?> sampleCategory = row.getSampleCategoryById(sampleCategoryId);
- BenthosBatchRowModel firstAncestor = row.getFirstAncestor(sampleCategory);
-
// set category value
- identifier.setCategoryValue(firstAncestor, newValue);
+ identifier.setCategoryValue(row, newValue);
// update row shell
- updateShell(firstAncestor, columnIndex);
+ updateShell(row, columnIndex);
}
protected void updateShell(BenthosBatchRowModel entry, int columnIndex) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-09-25 07:22:58 UTC (rev 1221)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-09-25 10:48:17 UTC (rev 1222)
@@ -518,9 +518,13 @@
SampleCategoryModelEntry category =
sampleCategoryModel.getCategoryById(sampleCategoryId);
+ // get the first ancestor row using this category
+ BenthosBatchRowModel firstAncestorRow =
+ row.getFirstAncestor(sampleCategoryId);
+
// get all used values for this category
Set<Serializable> used = getSampleUsedValues(
- row, sampleCategoryId);
+ firstAncestorRow, sampleCategoryId);
if (category.getCaracteristic().isNumericType()) {
@@ -901,11 +905,15 @@
// get his sample category
Integer sampleCategoryId = tableModel.getSampleCategoryId(columnIndex);
- SampleCategoryModelEntry sampleCategory = sampleCategoryModel.getCategoryById(sampleCategoryId);
- Caracteristic caracteristic = sampleCategory.getCaracteristic();
+ SampleCategoryModelEntry sampleCategoryEntry = sampleCategoryModel.getCategoryById(sampleCategoryId);
+ Caracteristic caracteristic = sampleCategoryEntry.getCaracteristic();
+ // get the first ancestor row using this category
+ BenthosBatchRowModel firstAncestorRow =
+ selectedRow.getFirstAncestor(sampleCategoryId);
+
// get used values
- Set<Serializable> usedValues = getSampleUsedValues(selectedRow,
+ Set<Serializable> usedValues = getSampleUsedValues(firstAncestorRow,
sampleCategoryId);
// get the new selected value for this category
@@ -979,10 +987,12 @@
if (selectedItem != null) {
// update rows values
- tableModel.updateSampleCategorieValue(selectedRow,
- sampleCategoryId,
+ tableModel.updateSampleCategorieValue(firstAncestorRow,
columnIndex,
selectedItem);
+
+ // save the first ancestor row with the modified category value
+ saveRow(firstAncestorRow);
}
}
@@ -1364,16 +1374,12 @@
protected Set<Serializable> getSampleUsedValues(BenthosBatchRowModel row,
int sampleCategoryId) {
- // get the first ancestor for the sample category
- SampleCategory<?> sampleCategory = row.getSampleCategoryById(sampleCategoryId);
- BenthosBatchRowModel firstAncestor = row.getFirstAncestor(sampleCategory);
-
Set<Serializable> usedValues = Sets.newHashSet();
List<BenthosBatchRowModel> childs;
- if (firstAncestor.isBatchRoot()) {
+ if (row.isBatchRoot()) {
// on a root must take all his brothers (but have no common ancestor...)
- Species species = firstAncestor.getSpecies();
+ Species species = row.getSpecies();
childs = Lists.newArrayList();
for (BenthosBatchRowModel rowToScan : getModel().getRows()) {
if (rowToScan.isBatchRoot() && species.equals(rowToScan.getSpecies())) {
@@ -1382,7 +1388,7 @@
}
} else {
// on a son, must take all the brother directly from his father
- BenthosBatchRowModel parentBatch = firstAncestor.getParentBatch();
+ BenthosBatchRowModel parentBatch = row.getParentBatch();
childs = parentBatch.getChildBatch();
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-09-25 07:22:58 UTC (rev 1221)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-09-25 10:48:17 UTC (rev 1222)
@@ -576,6 +576,12 @@
//-- Other properties --//
//------------------------------------------------------------------------//
+ public SpeciesBatchRowModel getFirstAncestor(Integer sampleCategoryId) {
+ SampleCategory<?> sampleCategory = getSampleCategoryById(sampleCategoryId);
+ SpeciesBatchRowModel firstAncestor = getFirstAncestor(sampleCategory);
+ return firstAncestor;
+ }
+
public List<SpeciesBatchRowModel> getChildBatch() {
return childBatch;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-09-25 07:22:58 UTC (rev 1221)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-09-25 10:48:17 UTC (rev 1222)
@@ -264,7 +264,7 @@
}
/**
- * Update the sample category value of all childs of the given {@code row}.
+ * Update the sample category value of the given {@code row}.
*
* @param row the row to walk through
* @param columnIndex index of the column where the sample category is
@@ -272,22 +272,17 @@
* @since 2.6
*/
public void updateSampleCategorieValue(SpeciesBatchRowModel row,
- int sampleCategoryId,
int columnIndex,
Serializable newValue) {
SampleCategoryColumnIdentifier<SpeciesBatchRowModel> identifier =
(SampleCategoryColumnIdentifier<SpeciesBatchRowModel>) getIdentifier(columnIndex);
- // get the first ancestor using the category to update
- SampleCategory<?> sampleCategory = row.getSampleCategoryById(sampleCategoryId);
- SpeciesBatchRowModel firstAncestor = row.getFirstAncestor(sampleCategory);
-
// set category value
- identifier.setCategoryValue(firstAncestor, newValue);
+ identifier.setCategoryValue(row, newValue);
// update row shell
- updateShell(firstAncestor, columnIndex);
+ updateShell(row, columnIndex);
}
protected void updateShell(SpeciesBatchRowModel entry, int columnIndex) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-09-25 07:22:58 UTC (rev 1221)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-09-25 10:48:17 UTC (rev 1222)
@@ -521,9 +521,13 @@
SampleCategoryModelEntry category =
sampleCategoryModel.getCategoryById(sampleCategoryId);
+ // get the first ancestor row using this category
+ SpeciesBatchRowModel firstAncestorRow =
+ row.getFirstAncestor(sampleCategoryId);
+
// get all used values for this category
Set<Serializable> used = getSampleUsedValues(
- row, sampleCategoryId);
+ firstAncestorRow, sampleCategoryId);
if (category.getCaracteristic().isNumericType()) {
@@ -903,11 +907,15 @@
// get his sample category
Integer sampleCategoryId = tableModel.getSampleCategoryId(columnIndex);
- SampleCategoryModelEntry sampleCategory = sampleCategoryModel.getCategoryById(sampleCategoryId);
- Caracteristic caracteristic = sampleCategory.getCaracteristic();
+ SampleCategoryModelEntry sampleCategoryEntry = sampleCategoryModel.getCategoryById(sampleCategoryId);
+ Caracteristic caracteristic = sampleCategoryEntry.getCaracteristic();
- // get used values
- Set<Serializable> usedValues = getSampleUsedValues(selectedRow,
+ // get the first ancestor row using this category
+ SpeciesBatchRowModel firstAncestorRow =
+ selectedRow.getFirstAncestor(sampleCategoryId);
+
+ // get used values of the category
+ Set<Serializable> usedValues = getSampleUsedValues(firstAncestorRow,
sampleCategoryId);
// get the new selected value for this category
@@ -981,10 +989,12 @@
if (selectedItem != null) {
// update rows values
- tableModel.updateSampleCategorieValue(selectedRow,
- sampleCategoryId,
+ tableModel.updateSampleCategorieValue(firstAncestorRow,
columnIndex,
selectedItem);
+
+ // save the first ancestor row with the modified category value
+ saveRow(firstAncestorRow);
}
}
@@ -1367,16 +1377,16 @@
protected Set<Serializable> getSampleUsedValues(SpeciesBatchRowModel row,
int sampleCategoryId) {
- // get the first ancestor for the sample category
- SampleCategory<?> sampleCategory = row.getSampleCategoryById(sampleCategoryId);
- SpeciesBatchRowModel firstAncestor = row.getFirstAncestor(sampleCategory);
+// // get the first ancestor for the sample category
+// SampleCategory<?> sampleCategory = row.getSampleCategoryById(sampleCategoryId);
+// SpeciesBatchRowModel firstAncestor = row.getFirstAncestor(sampleCategory);
Set<Serializable> usedValues = Sets.newHashSet();
List<SpeciesBatchRowModel> childs;
- if (firstAncestor.isBatchRoot()) {
+ if (row.isBatchRoot()) {
// on a root must take all his brothers (but have no common ancestor...)
- Species species = firstAncestor.getSpecies();
+ Species species = row.getSpecies();
childs = Lists.newArrayList();
for (SpeciesBatchRowModel rowToScan : getModel().getRows()) {
if (rowToScan.isBatchRoot() && species.equals(rowToScan.getSpecies())) {
@@ -1385,7 +1395,7 @@
}
} else {
// on a son, must take all the brother directly from his father
- SpeciesBatchRowModel parentBatch = firstAncestor.getParentBatch();
+ SpeciesBatchRowModel parentBatch = row.getParentBatch();
childs = parentBatch.getChildBatch();
}
1
0
25 Sep '13
Author: tchemit
Date: 2013-09-25 09:22:58 +0200 (Wed, 25 Sep 2013)
New Revision: 1221
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1221
Log:
fixes #3315: [CAPTURE] pouvoir modifier la valeur de la cat?\195?\169gorisation d'un lot
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategory.java
trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties
trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryColumnIdentifier.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategory.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategory.java 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategory.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -40,6 +40,8 @@
public static final String PROPERTY_CATEGORY_WEIGHT = "categoryWeight";
+ public static final String PROPERTY_CATEGORY_VALUE = "categoryValue";
+
/**
* Sample category definition.
*
Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-09-25 07:22:58 UTC (rev 1221)
@@ -1,5 +1,5 @@
#Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo
-#Tue Sep 24 16:21:02 CEST 2013
+#Tue Sep 24 18:46:35 CEST 2013
tutti.config.help=config.html
tutti.createAccidentalBatch.action.cancel.help=editFishingOperation.html\#captureCapturesAccidentellesActions
tutti.createAccidentalBatch.action.saveAndClose.help=editFishingOperation.html\#captureCapturesAccidentellesActions
@@ -26,8 +26,8 @@
tutti.createIndividualObservationBatch.action.addSpecies.help=editFishingOperation.html\#captureObservationsIndividuellesActions
tutti.createIndividualObservationBatch.action.cancel.help=editFishingOperation.html\#captureObservationsIndividuellesActions
tutti.createIndividualObservationBatch.action.save.help=editFishingOperation.html\#captureObservationsIndividuellesActions
-tutti.createIndividualObservationBatch.action.saveAndClose.help=
-tutti.createIndividualObservationBatch.action.saveAndContinue.help=
+tutti.createIndividualObservationBatch.action.saveAndClose.help=editFishingOperation.html\#captureObservationsIndividuellesActions
+tutti.createIndividualObservationBatch.action.saveAndContinue.help=editFishingOperation.html\#captureObservationsIndividuellesActions
tutti.createIndividualObservationBatch.field.individualObservationLengthStepCaracteristic.help=editFishingOperation.html\#captureObservationsIndividuellesFields
tutti.createIndividualObservationBatch.field.individualObservationSize.help=editFishingOperation.html\#captureObservationsIndividuellesFields
tutti.createIndividualObservationBatch.field.individualObservationSpecies.help=editFishingOperation.html\#captureObservationsIndividuellesFields
@@ -38,9 +38,9 @@
tutti.createMarineLitterBatch.action.saveAndContinue.help=editFishingOperation.html\#captureMacroDechetsActions
tutti.createMarineLitterBatch.field.marineLitterCategory.help=editFishingOperation.html\#captureMacroDechetsFields
tutti.createMarineLitterBatch.field.marineLitterSizeCategory.help=editFishingOperation.html\#captureMacroDechetsFields
-tutti.createMarineLitterBatch.field.marineLitterWeight.help=
+tutti.createMarineLitterBatch.field.marineLitterWeight.help=editFishingOperation.html\#captureMacroDechetsFields
tutti.createMarineLitterBatch.field.number.help=editFishingOperation.html\#captureMacroDechetsFields
-tutti.createMarineLitterBatch.field.weight.help=
+tutti.createMarineLitterBatch.field.weight.help=editFishingOperation.html\#captureMacroDechetsFields
tutti.createMarineLitterBatch.help=editFishingOperation.html\#captureMacroDechets
tutti.createSpeciesBatch.action.addSpecies.help=editFishingOperation.html\#captureEspecesCreeLotActions
tutti.createSpeciesBatch.action.cancel.help=editFishingOperation.html\#captureEspecesCreeLotActions
@@ -68,6 +68,7 @@
tutti.editAccidentalBatch.action.importMultiPost.help=editFishingOperation.html\#captureCapturesAccidentellesActions
tutti.editAccidentalBatch.action.removeBatch.help=editFishingOperation.html\#captureCapturesAccidentellesActions
tutti.editAccidentalBatch.help=editFishingOperation.html\#captureCapturesAccidentelles
+tutti.editBenthosBatch.action.changeSampleCategory.help=editFishingOperation.html\#captureBenthosActions
tutti.editBenthosBatch.action.createBatch.help=editFishingOperation.html\#captureBenthosActions
tutti.editBenthosBatch.action.createMelag.help=editFishingOperation.html\#captureBenthosActions
tutti.editBenthosBatch.action.editFrequencies.help=editFishingOperation.html\#captureBenthosActions
@@ -94,8 +95,8 @@
tutti.editBenthosFrequencies.action.cancel.help=editFishingOperation.html\#captureBenthosActions
tutti.editBenthosFrequencies.action.generate.help=editFishingOperation.html\#captureBenthosActions
tutti.editBenthosFrequencies.action.save.help=editFishingOperation.html\#captureBenthosActions
-tutti.editBenthosFrequencies.action.saveAndClose.help=
-tutti.editBenthosFrequencies.action.saveAndContinue.help=
+tutti.editBenthosFrequencies.action.saveAndClose.help=editFishingOperation.html\#captureBenthosActions
+tutti.editBenthosFrequencies.action.saveAndContinue.help=editFishingOperation.html\#captureBenthosActions
tutti.editBenthosFrequencies.field.lengthStepCaracteristic.help=editFishingOperation.html\#captureBenthosFields
tutti.editBenthosFrequencies.field.maxStep.help=editFishingOperation.html\#captureBenthosFields
tutti.editBenthosFrequencies.field.minStep.help=editFishingOperation.html\#captureBenthosFields
@@ -231,6 +232,7 @@
tutti.editSampleCategoryModel.action.removeEntry.help=editSampleCategory.html\#actions
tutti.editSampleCategoryModel.action.save.help=editSampleCategory.html\#actions
tutti.editSampleCategoryModel.help=editSampleCategory.html
+tutti.editSpeciesBatch.action.changeSampleCategory.help=editFishingOperation.html\#captureEspecesActions
tutti.editSpeciesBatch.action.createBatch.help=editFishingOperation.html\#captureEspecesActions
tutti.editSpeciesBatch.action.createMelag.help=editFishingOperation.html\#captureEspecesActions
tutti.editSpeciesBatch.action.editFrequencies.help=editFishingOperation.html\#captureEspecesActions
@@ -251,10 +253,10 @@
tutti.editSpeciesBatch.help=editFishingOperation.html\#captureEspeces
tutti.editSpeciesFrequencies.action.cancel.help=editFishingOperation.html\#captureEspecesMensurationActions
tutti.editSpeciesFrequencies.action.generate.help=editFishingOperation.html\#captureEspecesMensurationActions
-tutti.editSpeciesFrequencies.action.reset.help=
+tutti.editSpeciesFrequencies.action.reset.help=editFishingOperation.html\#captureEspecesMensurationActions
tutti.editSpeciesFrequencies.action.save.help=editFishingOperation.html\#captureEspecesMensurationActions
-tutti.editSpeciesFrequencies.action.saveAndClose.help=
-tutti.editSpeciesFrequencies.action.saveAndContinue.help=
+tutti.editSpeciesFrequencies.action.saveAndClose.help=editFishingOperation.html\#captureEspecesMensurationActions
+tutti.editSpeciesFrequencies.action.saveAndContinue.help=editFishingOperation.html\#captureEspecesMensurationActions
tutti.editSpeciesFrequencies.field.lengthStepCaracteristic.help=editFishingOperation.html\#captureEspecesMensurationFields
tutti.editSpeciesFrequencies.field.maxStep.help=editFishingOperation.html\#captureEspecesMensurationFields
tutti.editSpeciesFrequencies.field.minStep.help=editFishingOperation.html\#captureEspecesMensurationFields
Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-09-25 07:22:58 UTC (rev 1221)
@@ -1,5 +1,5 @@
#Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo
-#Tue Sep 24 16:21:02 CEST 2013
+#Tue Sep 24 18:46:35 CEST 2013
tutti.config.help=config.html
tutti.createAccidentalBatch.action.cancel.help=editFishingOperation.html\#captureCapturesAccidentellesActions
tutti.createAccidentalBatch.action.saveAndClose.help=editFishingOperation.html\#captureCapturesAccidentellesActions
@@ -37,9 +37,9 @@
tutti.createMarineLitterBatch.action.saveAndContinue.help=editFishingOperation.html\#captureMacroDechetsActions
tutti.createMarineLitterBatch.field.marineLitterCategory.help=editFishingOperation.html\#captureMacroDechetsFields
tutti.createMarineLitterBatch.field.marineLitterSizeCategory.help=editFishingOperation.html\#captureMacroDechetsFields
-tutti.createMarineLitterBatch.field.marineLitterWeight.help=
+tutti.createMarineLitterBatch.field.marineLitterWeight.help=editFishingOperation.html\#captureMacroDechetsFields
tutti.createMarineLitterBatch.field.number.help=editFishingOperation.html\#captureMacroDechetsFields
-tutti.createMarineLitterBatch.field.weight.help=
+tutti.createMarineLitterBatch.field.weight.help=editFishingOperation.html\#captureMacroDechetsFields
tutti.createMarineLitterBatch.help=editFishingOperation.html\#captureMacroDechets
tutti.createSpeciesBatch.action.addSpecies.help=editFishingOperation.html\#captureEspecesCreeLotActions
tutti.createSpeciesBatch.action.cancel.help=editFishingOperation.html\#captureEspecesCreeLotActions
@@ -67,6 +67,7 @@
tutti.editAccidentalBatch.action.importMultiPost.help=editFishingOperation.html\#captureCapturesAccidentellesActions
tutti.editAccidentalBatch.action.removeBatch.help=editFishingOperation.html\#captureCapturesAccidentellesActions
tutti.editAccidentalBatch.help=editFishingOperation.html\#captureCapturesAccidentelles
+tutti.editBenthosBatch.action.changeSampleCategory.help=editFishingOperation.html\#captureBenthosActions
tutti.editBenthosBatch.action.createBatch.help=editFishingOperation.html\#captureBenthosActions
tutti.editBenthosBatch.action.createMelag.help=editFishingOperation.html\#captureBenthosActions
tutti.editBenthosBatch.action.editFrequencies.help=editFishingOperation.html\#captureBenthosActions
@@ -229,6 +230,7 @@
tutti.editSampleCategoryModel.action.removeEntry.help=editSampleCategory.html\#actions
tutti.editSampleCategoryModel.action.save.help=editSampleCategory.html\#actions
tutti.editSampleCategoryModel.help=editSampleCategory.html
+tutti.editSpeciesBatch.action.changeSampleCategory.help=editFishingOperation.html\#captureEspecesActions
tutti.editSpeciesBatch.action.createBatch.help=editFishingOperation.html\#captureEspecesActions
tutti.editSpeciesBatch.action.createMelag.help=editFishingOperation.html\#captureEspecesActions
tutti.editSpeciesBatch.action.editFrequencies.help=editFishingOperation.html\#captureEspecesActions
@@ -249,7 +251,7 @@
tutti.editSpeciesBatch.help=editFishingOperation.html\#captureEspeces
tutti.editSpeciesFrequencies.action.cancel.help=editFishingOperation.html\#captureEspecesMensurationActions
tutti.editSpeciesFrequencies.action.generate.help=editFishingOperation.html\#captureEspecesMensurationActions
-tutti.editSpeciesFrequencies.action.reset.help=
+tutti.editSpeciesFrequencies.action.reset.help=editFishingOperation.html\#captureEspecesMensurationActions
tutti.editSpeciesFrequencies.action.saveAndClose.help=editFishingOperation.html\#captureEspecesMensurationActions
tutti.editSpeciesFrequencies.action.saveAndContinue.help=editFishingOperation.html\#captureEspecesMensurationActions
tutti.editSpeciesFrequencies.field.lengthStepCaracteristic.help=editFishingOperation.html\#captureEspecesMensurationFields
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.java 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -26,6 +26,8 @@
import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
+import java.io.Serializable;
+
/**
* Contract for model using {@link SampleCategory}.
*
@@ -44,6 +46,8 @@
SampleCategory getSampleCategoryById(Integer sampleCategoryId);
+ void setSampleCategoryValue(Integer sampleCategoryId, Serializable value);
+
void setSampleCategoryWeight(Integer sampleCategoryId, Object value);
E getFirstAncestor(SampleCategory<?> entrySampleCategory);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryColumnIdentifier.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryColumnIdentifier.java 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryColumnIdentifier.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -27,6 +27,8 @@
import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+import java.io.Serializable;
+
/**
* @author tchemit <chemit(a)codelutin.com>
* @since 1.2
@@ -66,6 +68,11 @@
entry.setSampleCategoryWeight(getSampleCategoryId(), value);
}
+ public void setCategoryValue(R entry, Serializable value) {
+
+ entry.setSampleCategoryValue(getSampleCategoryId(), value);
+ }
+
public Integer getSampleCategoryId() {
return sampleCategoryId;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -324,6 +324,15 @@
}
@Override
+ public void setSampleCategoryValue(Integer sampleCategoryId, Serializable value) {
+ SampleCategory<?> sampleCategory =
+ getSampleCategoryById(sampleCategoryId);
+ TuttiUIUtil.setProperty(sampleCategory,
+ SampleCategory.PROPERTY_CATEGORY_VALUE, value);
+ firePropertyChange(PROPERTY_SAMPLE_CATEGORY_VALUE, null, sampleCategory);
+ }
+
+ @Override
public void setSampleCategoryWeight(Integer sampleCategoryId, Object value) {
SampleCategory<?> sampleCategory =
getSampleCategoryById(sampleCategoryId);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -37,6 +37,7 @@
import org.jdesktop.swingx.table.TableColumnModelExt;
import javax.swing.table.TableColumn;
+import java.io.Serializable;
import java.util.Enumeration;
import java.util.Set;
@@ -171,19 +172,9 @@
log.debug("First ancestor row: " + firstRowIndex);
}
- // must save this row now
+ // save this row and his shell
+ updateShell(firstAncestor, columnIndex);
- // get shell of the ancestor
- Set<BenthosBatchRowModel> shell = Sets.newHashSet();
- firstAncestor.collectShell(shell);
-
- for (BenthosBatchRowModel batchRowModel : shell) {
- int currentRowIndex = getRowIndex(batchRowModel);
- if (log.isDebugEnabled()) {
- log.debug("Update shell row: " + currentRowIndex);
- }
- fireTableCellUpdated(currentRowIndex, columnIndex);
- }
} else {
super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry);
}
@@ -253,4 +244,65 @@
}
return result;
}
+
+ /**
+ * Return the sample category id of a column or {@code null} if not on a
+ * sample category column.
+ *
+ * @param columnIndex index of the column to look at
+ * @return the sample category id of a column or {@code null} if not on a
+ * sample category column.
+ * @since 2.6
+ */
+ public Integer getSampleCategoryId(int columnIndex) {
+ Integer result = null;
+ ColumnIdentifier<BenthosBatchRowModel> identifier = getIdentifier(columnIndex);
+ if (sampleCols.contains(identifier)) {
+ SampleCategoryColumnIdentifier<BenthosBatchRowModel> sampleId = (SampleCategoryColumnIdentifier<BenthosBatchRowModel>) identifier;
+ result = sampleId.getSampleCategoryId();
+ }
+ return result;
+ }
+
+ /**
+ * Update the sample category value of all childs of the given {@code row}.
+ *
+ * @param row the row to walk through
+ * @param columnIndex index of the column where the sample category is
+ * @param newValue new sample category value to set
+ * @since 2.6
+ */
+ public void updateSampleCategorieValue(BenthosBatchRowModel row,
+ int sampleCategoryId,
+ int columnIndex,
+ Serializable newValue) {
+
+ SampleCategoryColumnIdentifier<BenthosBatchRowModel> identifier =
+ (SampleCategoryColumnIdentifier<BenthosBatchRowModel>) getIdentifier(columnIndex);
+
+ // get the first ancestor using the category to update
+ SampleCategory<?> sampleCategory = row.getSampleCategoryById(sampleCategoryId);
+ BenthosBatchRowModel firstAncestor = row.getFirstAncestor(sampleCategory);
+
+ // set category value
+ identifier.setCategoryValue(firstAncestor, newValue);
+
+ // update row shell
+ updateShell(firstAncestor, columnIndex);
+ }
+
+ protected void updateShell(BenthosBatchRowModel entry, int columnIndex) {
+
+ Set<BenthosBatchRowModel> shell = Sets.newHashSet();
+ entry.collectShell(shell);
+ shell.add(entry);
+
+ for (BenthosBatchRowModel batchRowModel : shell) {
+ int currentRowIndex = getRowIndex(batchRowModel);
+ if (log.isDebugEnabled()) {
+ log.debug("Update shell row: " + currentRowIndex);
+ }
+ fireTableCellUpdated(currentRowIndex, columnIndex);
+ }
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 2013-09-25 07:22:58 UTC (rev 1221)
@@ -186,6 +186,15 @@
_help: {"tutti.editBenthosBatch.action.splitBatch.help"};
}
+#changeSampleCategoryMenu {
+ actionIcon: batch-split;
+ text: "tutti.editBenthosBatch.action.changeSampleCategory";
+ toolTipText: "tutti.editBenthosBatch.action.changeSampleCategory.tip";
+ i18nMnemonic: "tutti.editBenthosBatch.action.changeSampleCategory.mnemonic";
+ enabled: {model.isTableViewModeAll() && model.isChangeSampleCategoryEnabled()};
+ _help: {"tutti.editBenthosBatch.action.changeSampleCategory.help"};
+}
+
#removeBenthosBatchMenu {
actionIcon: batch-delete;
text: "tutti.editBenthosBatch.action.removeBatch";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx 2013-09-25 07:22:58 UTC (rev 1221)
@@ -77,6 +77,8 @@
<JPopupMenu id='tablePopup'>
<JMenuItem id='splitBenthosBatchMenu'
onActionPerformed='handler.splitBatch()'/>
+ <JMenuItem id='changeSampleCategoryMenu'
+ onActionPerformed='handler.changeBatchCategory()'/>
<JMenuItem id='removeBenthosBatchMenu'/>
<JMenuItem id='removeBenthosSubBatchMenu'/>
<JMenuItem id='renameBenthosBatchMenu'/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -26,6 +26,7 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
@@ -36,6 +37,7 @@
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocols;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.DecoratorService;
@@ -68,6 +70,8 @@
import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.editor.NumberEditor;
+import jaxx.runtime.swing.renderer.DecoratorListCellRenderer;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
@@ -83,6 +87,7 @@
import org.nuiton.decorator.Decorator;
import org.nuiton.validator.NuitonValidatorResult;
+import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.RowFilter;
@@ -241,7 +246,6 @@
}
model.setRows(rows);
- recomputeBatchActionEnable();
}
//------------------------------------------------------------------------//
@@ -320,9 +324,6 @@
}
saveRow(firstAncestorRow);
- // when row valid state has changed, recompute action enabled states
- recomputeBatchActionEnable();
-
cleanrRowMonitor();
return;
@@ -333,9 +334,6 @@
}
saveSelectedRowIfNeeded();
-
- // when row valid state has changed, recompute action enabled states
- recomputeBatchActionEnable();
}
@Override
@@ -380,28 +378,6 @@
}
@Override
- protected void onRowValidStateChanged(int rowIndex,
- BenthosBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- super.onRowValidStateChanged(rowIndex, row, oldValue, newValue);
-
- // when row valid state has changed, recompute action enabled states
- recomputeBatchActionEnable();
- }
-
- @Override
- protected void onAfterSelectedRowChanged(int oldRowIndex,
- BenthosBatchRowModel oldRow,
- int newRowIndex,
- BenthosBatchRowModel newRow) {
- super.onAfterSelectedRowChanged(oldRowIndex, oldRow, newRowIndex, newRow);
-
- // when selected row has changed, recompute action enabled states
- recomputeBatchActionEnable();
- }
-
- @Override
protected void addHighlighters(JXTable table) {
super.addHighlighters(table);
@@ -473,6 +449,163 @@
table.addHighlighter(attachmentHighlighter);
}
+ @Override
+ protected void beforeOpenPopup(int rowIndex, int columnIndex) {
+ super.beforeOpenPopup(rowIndex, columnIndex);
+
+ boolean enableAdd = true;
+
+ boolean enableRename = false;
+ boolean enableSplit = false;
+ boolean enableChangeSampleCategory = false;
+ boolean enableRemove = false;
+ boolean enableRemoveSub = false;
+ boolean enableCreateMelag = false;
+ boolean enableEditFrequencies = false;
+
+ if (rowIndex != -1) {
+
+ // there is a selected row
+
+
+ //TODO If there is some sub-batch, can remove them
+ //TODO If there is no sub-batch, can split current batch
+
+ BenthosBatchTableModel tableModel = getTableModel();
+ BenthosBatchRowModel row = tableModel.getEntry(rowIndex);
+ int selectedRowCount = getTable().getSelectedRowCount();
+
+ // can edit frequencies on a single selected leaf row
+
+
+ enableSplit = true;
+
+ // action with single selection
+ enableRemove = selectedRowCount == 1;
+ enableRemoveSub = selectedRowCount == 1;
+ enableRename = selectedRowCount == 1;
+ enableCreateMelag = selectedRowCount > 1;
+ enableEditFrequencies = selectedRowCount == 1;
+ enableChangeSampleCategory = selectedRowCount == 1 && tableModel.isCellEditable(rowIndex, columnIndex);
+
+ if (enableSplit) {
+
+ // can split if selected batch is a leaf
+
+ Integer lastSamplingId = sampleCategoryModel.getLastCategoryId();
+
+ enableSplit = row.isBatchLeaf()
+ && selectedRowCount == 1
+ && ObjectUtils.notEqual(lastSamplingId, row.getFinestCategory().getCategoryId())
+ && row.getNumber() == null
+ && (row.getComputedNumber() == null
+ || row.getComputedNumber() == 0);
+ }
+
+ if (enableChangeSampleCategory) {
+
+ // can change category if there is still a brother category free
+ Integer sampleCategoryId =
+ tableModel.getSampleCategoryId(columnIndex);
+
+ if (sampleCategoryId == null) {
+
+ // not on a sample category column
+ enableChangeSampleCategory = false;
+ } else {
+
+ // get category
+ SampleCategoryModelEntry category =
+ sampleCategoryModel.getCategoryById(sampleCategoryId);
+
+ // get all used values for this category
+ Set<Serializable> used = getSampleUsedValues(
+ row, sampleCategoryId);
+
+ if (category.getCaracteristic().isNumericType()) {
+
+ // if number then can always change it
+
+ } else {
+
+ // get all possible values
+
+ List<CaracteristicQualitativeValue> available =
+ Lists.newArrayList(category.getCaracteristic().getQualitativeValue());
+ available.removeAll(used);
+
+ // action possible only if there is still some available values
+ enableChangeSampleCategory = !available.isEmpty();
+ }
+ }
+
+ }
+
+ if (enableEditFrequencies) {
+
+ // can edit frequencies only on a leaf
+ enableEditFrequencies = row.isBatchLeaf();
+ }
+
+ if (enableRename) {
+
+ // can rename if selected batch is a parent
+ enableRename = row.isBatchRoot();
+ }
+
+ if (enableRemove) {
+
+ // can always remove the batch
+ // no more test
+ }
+
+ if (enableRemoveSub) {
+
+ // can remove sub batch if selected batch is not a leaf
+ enableRemoveSub = !row.isBatchLeaf();
+ }
+
+ if (enableCreateMelag) {
+
+ JXTable table = getTable();
+
+ // can add species to a melag if several root are selected
+ int[] selectedRows = table.getSelectedRows();
+ for (int selectedRowIndex : selectedRows) {
+ BenthosBatchRowModel selectedRow =
+ tableModel.getEntry(selectedRowIndex);
+
+ if (!selectedRow.isBatchRoot()) {
+ enableCreateMelag = false;
+ break;
+ }
+ }
+ }
+ }
+ BenthosBatchUIModel model = getModel();
+ model.setCreateBatchEnabled(enableAdd);
+ model.setSplitBatchEnabled(enableSplit);
+ model.setChangeSampleCategoryEnabled(enableChangeSampleCategory);
+ model.setRemoveBatchEnabled(enableRemove);
+ model.setRemoveSubBatchEnabled(enableRemoveSub);
+ model.setRenameBatchEnabled(enableRename);
+ model.setCreateMelagEnabled(enableCreateMelag);
+ model.setEditFrequenciesEnabled(enableEditFrequencies);
+
+ if (log.isInfoEnabled()) {
+ StringBuilder builder = new StringBuilder("actions for (" + rowIndex + "," + columnIndex + "):");
+ builder.append("\nenableAdd: ").append(enableAdd);
+ builder.append("\nenableSplit: ").append(enableSplit);
+ builder.append("\nenableChangeSampleCategory: ").append(enableChangeSampleCategory);
+ builder.append("\nenableRemove: ").append(enableRemove);
+ builder.append("\nenableRemoveSub: ").append(enableRemoveSub);
+ builder.append("\nenableRename: ").append(enableRename);
+ builder.append("\nenableCreateMelag: ").append(enableCreateMelag);
+ builder.append("\nenableEditFrequencies: ").append(enableEditFrequencies);
+ log.info(builder.toString());
+ }
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@@ -686,8 +819,6 @@
);
}
}
-
- recomputeBatchActionEnable();
}
public void editFrequencies() {
@@ -754,6 +885,107 @@
}
}
+ public void changeBatchCategory() {
+
+ // get table model
+ BenthosBatchTableModel tableModel = getTableModel();
+
+ // get selected row
+ int rowIndex = getTable().getSelectedRow();
+
+ // get selected column
+ int columnIndex = getTable().getSelectedColumn();
+
+ // get selected row
+ BenthosBatchRowModel selectedRow = tableModel.getEntry(rowIndex);
+
+ // get his sample category
+ Integer sampleCategoryId = tableModel.getSampleCategoryId(columnIndex);
+ SampleCategoryModelEntry sampleCategory = sampleCategoryModel.getCategoryById(sampleCategoryId);
+ Caracteristic caracteristic = sampleCategory.getCaracteristic();
+
+ // get used values
+ Set<Serializable> usedValues = getSampleUsedValues(selectedRow,
+ sampleCategoryId);
+
+ // get the new selected value for this category
+ Serializable selectedItem;
+
+ String categoryDecorated = decorate(caracteristic, DecoratorService.CARACTERISTIC_PARAMETER_ONLY);
+ String dialogTitle = _("tutti.editBenthosBatch.title.changeSampleCategoryValue", categoryDecorated);
+
+ if (caracteristic.isNumericType()) {
+
+ // open a simple number editor
+ NumberEditor editor = new NumberEditor();
+ editor.setNumberPattern(TuttiUI.DECIMAL3_PATTERN);
+ editor.setUseSign(false);
+ editor.setUseFloat(true);
+ editor.setShowPopupButton(false);
+ editor.setShowReset(false);
+
+ int response = JOptionPane.showConfirmDialog(
+ getUI(),
+ editor,
+ dialogTitle,
+ JOptionPane.OK_CANCEL_OPTION);
+
+ if (response == JOptionPane.OK_OPTION) {
+ selectedItem = editor.getModel();
+ } else {
+ // user cancel selection
+ selectedItem = null;
+ }
+
+ if (usedValues.contains(selectedItem)) {
+
+ // impossible de choisir cette valeur (déjà utilisée)
+ JOptionPane.showMessageDialog(
+ getTopestUI(),
+ _("tutti.editBenthosBatch.error.sampleCategoryValue.notAvailable", selectedItem, categoryDecorated));
+ selectedItem = null;
+ }
+
+ } else {
+
+ // open a combobox to select new value
+
+ List<CaracteristicQualitativeValue> availableValues =
+ Lists.newArrayList(caracteristic.getQualitativeValue());
+ availableValues.removeAll(usedValues);
+
+ JComboBox editor = new JComboBox();
+ editor.setRenderer(new DecoratorListCellRenderer(getDecorator(CaracteristicQualitativeValue.class, null)));
+ SwingUtil.fillComboBox(editor, availableValues, availableValues.get(0));
+
+ int response = JOptionPane.showConfirmDialog(
+ getTopestUI(),
+ editor,
+ dialogTitle,
+ JOptionPane.OK_CANCEL_OPTION);
+
+ if (response == JOptionPane.OK_OPTION) {
+ selectedItem = (CaracteristicQualitativeValue) editor.getSelectedItem();
+ } else {
+ // user cancel selection
+ selectedItem = null;
+ }
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("New selected category: " + selectedItem);
+ }
+
+ if (selectedItem != null) {
+
+ // update rows values
+ tableModel.updateSampleCategorieValue(selectedRow,
+ sampleCategoryId,
+ columnIndex,
+ selectedItem);
+ }
+ }
+
public void splitBatch(SampleCategoryModelEntry sampleCategoryDef,
List<SplitBenthosBatchRowModel> rows,
Float totalRowWeight) {
@@ -805,8 +1037,6 @@
BenthosBatchUIModel model = getModel();
model.setLeafNumber(model.getLeafNumber() + newBatches.size() - 1);
-
- recomputeBatchActionEnable();
}
public void updateTotalFromFrequencies(BenthosBatchRowModel row) {
@@ -824,8 +1054,6 @@
}
row.setComputedNumber(totalNumber);
row.getFinestCategory().setOnlyOneFrequency(onlyOneFrequency);
-
- recomputeBatchActionEnable();
}
public void saveRows(Iterable<BenthosBatchRowModel> rows) {
@@ -835,190 +1063,10 @@
}
}
- protected void saveRow(BenthosBatchRowModel row) {
-
- FishingOperation fishingOperation = getModel().getFishingOperation();
-
- Preconditions.checkNotNull(fishingOperation);
- Preconditions.checkNotNull(row.getSpecies());
- Preconditions.checkNotNull(row.getFinestCategory());
- Preconditions.checkNotNull(row.getFinestCategory().getCategoryId());
- Preconditions.checkNotNull(row.getFinestCategory().getCategoryValue());
-
-// SampleCategory<?> sampleCategory = row.getFinestCategory();
-// Preconditions.checkNotNull(sampleCategory);
-// Preconditions.checkNotNull(sampleCategory.getCategoryId());
-// Preconditions.checkNotNull(sampleCategory.getCategoryValue());
-
- BenthosBatch entityToSave = row.toEntity();
-
- entityToSave.setFishingOperation(fishingOperation);
-
- BenthosBatchRowModel parent = row.getParentBatch();
- if (parent != null) {
- //FIXME Check no need to convert parent weight ? :(
- entityToSave.setParentBatch(parent.toBean());
- }
-
-// // apply sample category
-// entityToSave.setSampleCategoryId(sampleCategory.getCategoryId());
-// entityToSave.setSampleCategoryValue(sampleCategory.getCategoryValue());
-//
-// // convert sample category weight
-// Float categoryWeight = sampleCategory.getCategoryWeight();
-// entityToSave.setSampleCategoryWeight(weightUnit.toEntity(categoryWeight));
-
- if (TuttiEntities.isNew(entityToSave)) {
-
- BenthosBatchRowModel batchParent = row.getParentBatch();
- String parentBatchId = null;
-
- if (batchParent != null) {
- parentBatchId = batchParent.getId();
- }
-
- if (log.isInfoEnabled()) {
- log.info("Persist new species batch with parentId: " +
- parentBatchId);
- }
- entityToSave = persistenceService.createBenthosBatch(entityToSave,
- parentBatchId);
- row.setId(entityToSave.getId());
- } else {
- if (log.isInfoEnabled()) {
- log.info("Persist existing species batch: " + entityToSave.getId() + " (parent : " + entityToSave.getParentBatch() + ")");
- }
- persistenceService.saveBenthosBatch(entityToSave);
- }
-
- List<BenthosFrequencyRowModel> frequencyRows = row.getFrequency();
-
- List<BenthosBatchFrequency> frequency =
- BenthosFrequencyRowModel.toEntity(
- frequencyRows,
- entityToSave);
-
- if (log.isInfoEnabled()) {
- log.info("Will save " + frequency.size() + " frequencies.");
- }
- frequency = persistenceService.saveBenthosBatchFrequency(
- entityToSave.getId(), frequency);
-
- // push it back to row model
- frequencyRows = BenthosFrequencyRowModel.fromEntity(weightUnit, frequency);
- row.setFrequency(frequencyRows);
-
- getModel().fireBatchUpdated(row);
- }
-
public String getFilterBenthosBatchRootButtonText(int rootNumber) {
return _("tutti.editBenthosBatch.filterBatch.mode.root", rootNumber);
}
- protected void recomputeBatchActionEnable() {
-
- int rowIndex = getTable().getSelectedRow();
-
- //TODO Improve this test
- boolean enableAdd = true;
-
- boolean enableRename = false;
- boolean enableSplit = false;
- boolean enableRemove = false;
- boolean enableRemoveSub = false;
- boolean enableCreateMelag = false;
- boolean enableEditFrequencies = false;
-
- if (rowIndex != -1) {
-
- // there is a selected row
-
-
- //TODO If there is some sub-batch, can remove them
- //TODO If there is no sub-batch, can split current batch
-
- BenthosBatchTableModel tableModel = getTableModel();
- BenthosBatchRowModel row = tableModel.getEntry(rowIndex);
- int selectedRowCount = getTable().getSelectedRowCount();
-
- // can edit frequencies on a single selected leaf row
-
-
- enableSplit = true;
-
- // action with single selection
- enableRemove = selectedRowCount == 1;
- enableRemoveSub = selectedRowCount == 1;
- enableRename = selectedRowCount == 1;
- enableCreateMelag = selectedRowCount > 1;
- enableEditFrequencies = selectedRowCount == 1;
-
- if (enableSplit) {
-
- // can split if selected batch is a leaf
-
- Integer lastSamplingId = sampleCategoryModel.getLastCategoryId();
-
- enableSplit = row.isBatchLeaf()
- && selectedRowCount == 1
- && ObjectUtils.notEqual(lastSamplingId, row.getFinestCategory().getCategoryId())
- && row.getNumber() == null
- && (row.getComputedNumber() == null
- || row.getComputedNumber() == 0);
- }
-
- if (enableEditFrequencies) {
-
- // can edit frequencies only on a leaf
- enableEditFrequencies = row.isBatchLeaf();
- }
-
- if (enableRename) {
-
- // can rename if selected batch is a parent
- enableRename = row.isBatchRoot();
- }
-
- if (enableRemove) {
-
- // can always remove the batch
- // no more test
- }
-
- if (enableRemoveSub) {
-
- // can remove sub batch if selected batch is not a leaf
- enableRemoveSub = !row.isBatchLeaf();
- }
-
- if (enableCreateMelag) {
-
- JXTable table = getTable();
-
- // can add species to a melag if several root are selected
- int[] selectedRows = table.getSelectedRows();
- for (int selectedRowIndex : selectedRows) {
- BenthosBatchRowModel selectedRow =
- tableModel.getEntry(selectedRowIndex);
-
- if (!selectedRow.isBatchRoot()) {
- enableCreateMelag = false;
- break;
- }
- }
- }
- }
-
- BenthosBatchUIModel model = getModel();
- model.setCreateBatchEnabled(enableAdd);
- model.setSplitBatchEnabled(enableSplit);
- model.setRemoveBatchEnabled(enableRemove);
- model.setRemoveSubBatchEnabled(enableRemoveSub);
- model.setRenameBatchEnabled(enableRename);
- model.setCreateMelagEnabled(enableCreateMelag);
- model.setEditFrequenciesEnabled(enableEditFrequencies);
- }
-
public void collectChildren(BenthosBatchRowModel row,
Set<BenthosBatchRowModel> collectedRows) {
@@ -1112,6 +1160,101 @@
return newRow;
}
+ public void removeFromSpeciesUsed(BenthosBatchRowModel row) {
+ Preconditions.checkNotNull(row);
+ Preconditions.checkNotNull(row.getSpecies());
+ SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
+ CaracteristicQualitativeValue categoryValue = (CaracteristicQualitativeValue) firstSampleCategory.getCategoryValue();
+ Preconditions.checkNotNull(firstSampleCategory);
+ if (log.isInfoEnabled()) {
+ log.info("Remove from speciesUsed: " + decorate(categoryValue) + " - " + decorate(row.getSpecies()));
+ }
+ BenthosBatchUIModel model = getModel();
+ model.getSpeciesUsed().remove(categoryValue, row.getSpecies());
+
+ if (row.isBatchRoot()) {
+ model.setRootNumber(model.getRootNumber() - 1);
+ }
+ }
+
+ public Species openAddSpeciesDialog(String title, List<Species> species) {
+ SelectSpeciesUI dialogContent = new SelectSpeciesUI(ui);
+ SelectSpeciesUIModel model = dialogContent.getModel();
+ model.setSelectedSpecies(null);
+ model.setSpecies(species);
+
+ openDialog(dialogContent, title, new Dimension(400, 130));
+
+ return model.getSelectedSpecies();
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected void saveRow(BenthosBatchRowModel row) {
+
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+
+ Preconditions.checkNotNull(fishingOperation);
+ Preconditions.checkNotNull(row.getSpecies());
+ Preconditions.checkNotNull(row.getFinestCategory());
+ Preconditions.checkNotNull(row.getFinestCategory().getCategoryId());
+ Preconditions.checkNotNull(row.getFinestCategory().getCategoryValue());
+
+ BenthosBatch entityToSave = row.toEntity();
+
+ entityToSave.setFishingOperation(fishingOperation);
+
+ BenthosBatchRowModel parent = row.getParentBatch();
+ if (parent != null) {
+ //FIXME Check no need to convert parent weight ? :(
+ entityToSave.setParentBatch(parent.toBean());
+ }
+
+ if (TuttiEntities.isNew(entityToSave)) {
+
+ BenthosBatchRowModel batchParent = row.getParentBatch();
+ String parentBatchId = null;
+
+ if (batchParent != null) {
+ parentBatchId = batchParent.getId();
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("Persist new species batch with parentId: " +
+ parentBatchId);
+ }
+ entityToSave = persistenceService.createBenthosBatch(entityToSave,
+ parentBatchId);
+ row.setId(entityToSave.getId());
+ } else {
+ if (log.isInfoEnabled()) {
+ log.info("Persist existing species batch: " + entityToSave.getId() + " (parent : " + entityToSave.getParentBatch() + ")");
+ }
+ persistenceService.saveBenthosBatch(entityToSave);
+ }
+
+ List<BenthosFrequencyRowModel> frequencyRows = row.getFrequency();
+
+ List<BenthosBatchFrequency> frequency =
+ BenthosFrequencyRowModel.toEntity(
+ frequencyRows,
+ entityToSave);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will save " + frequency.size() + " frequencies.");
+ }
+ frequency = persistenceService.saveBenthosBatchFrequency(
+ entityToSave.getId(), frequency);
+
+ // push it back to row model
+ frequencyRows = BenthosFrequencyRowModel.fromEntity(weightUnit, frequency);
+ row.setFrequency(frequencyRows);
+
+ getModel().fireBatchUpdated(row);
+ }
+
protected void loadBatchRow(BenthosBatchRowModel parentRow,
BenthosBatchRowModel newRow,
Integer sampleCategoryId,
@@ -1164,23 +1307,6 @@
weightUnit);
}
- public void removeFromSpeciesUsed(BenthosBatchRowModel row) {
- Preconditions.checkNotNull(row);
- Preconditions.checkNotNull(row.getSpecies());
- SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
- CaracteristicQualitativeValue categoryValue = (CaracteristicQualitativeValue) firstSampleCategory.getCategoryValue();
- Preconditions.checkNotNull(firstSampleCategory);
- if (log.isInfoEnabled()) {
- log.info("Remove from speciesUsed: " + decorate(categoryValue) + " - " + decorate(row.getSpecies()));
- }
- BenthosBatchUIModel model = getModel();
- model.getSpeciesUsed().remove(categoryValue, row.getSpecies());
-
- if (row.isBatchRoot()) {
- model.setRootNumber(model.getRootNumber() - 1);
- }
- }
-
protected void addToSpeciesUsed(BenthosBatchRowModel row) {
Preconditions.checkNotNull(row);
Preconditions.checkNotNull(row.getSpecies());
@@ -1198,17 +1324,6 @@
model.setRootNumber(model.getRootNumber() + 1);
}
- public Species openAddSpeciesDialog(String title, List<Species> species) {
- SelectSpeciesUI dialogContent = new SelectSpeciesUI(ui);
- SelectSpeciesUIModel model = dialogContent.getModel();
- model.setSelectedSpecies(null);
- model.setSpecies(species);
-
- openDialog(dialogContent, title, new Dimension(400, 130));
-
- return model.getSelectedSpecies();
- }
-
protected BenthosBatch convertRowToEntity(BenthosBatchRowModel row, boolean convertParent) {
SampleCategory<?> sampleCategory = row.getFinestCategory();
Preconditions.checkNotNull(sampleCategory);
@@ -1236,4 +1351,45 @@
return catchBean;
}
+
+ /**
+ * Return all the sample category values (of the given
+ * {@code sampleCategoryId}) for all brothers of the given {@code row}.
+ *
+ * @param row the row
+ * @param sampleCategoryId id of the sample category to seek in brothers of the given row
+ * @return all the sample category values (of the given
+ * {@code sampleCategoryId}) for all brothers of the given {@code row}.
+ */
+ protected Set<Serializable> getSampleUsedValues(BenthosBatchRowModel row,
+ int sampleCategoryId) {
+
+ // get the first ancestor for the sample category
+ SampleCategory<?> sampleCategory = row.getSampleCategoryById(sampleCategoryId);
+ BenthosBatchRowModel firstAncestor = row.getFirstAncestor(sampleCategory);
+
+ Set<Serializable> usedValues = Sets.newHashSet();
+ List<BenthosBatchRowModel> childs;
+ if (firstAncestor.isBatchRoot()) {
+
+ // on a root must take all his brothers (but have no common ancestor...)
+ Species species = firstAncestor.getSpecies();
+ childs = Lists.newArrayList();
+ for (BenthosBatchRowModel rowToScan : getModel().getRows()) {
+ if (rowToScan.isBatchRoot() && species.equals(rowToScan.getSpecies())) {
+ childs.add(rowToScan);
+ }
+ }
+ } else {
+ // on a son, must take all the brother directly from his father
+ BenthosBatchRowModel parentBatch = firstAncestor.getParentBatch();
+ childs = parentBatch.getChildBatch();
+ }
+
+ for (BenthosBatchRowModel child : childs) {
+ SampleCategory<?> category = child.getSampleCategoryById(sampleCategoryId);
+ usedValues.add(category.getCategoryValue());
+ }
+ return usedValues;
+ }
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -51,6 +51,8 @@
public static final String PROPERTY_SPLIT_BATCH_ENABLED = "splitBatchEnabled";
+ public static final String PROPERTY_CHANGE_SAMPLE_CATEGORY_ENABLED = "changeSampleCategoryEnabled";
+
public static final String PROPERTY_REMOVE_SUB_BATCH_ENABLED = "removeSubBatchEnabled";
public static final String PROPERTY_RENAME_BATCH_ENABLED = "renameBatchEnabled";
@@ -86,6 +88,13 @@
protected boolean splitBatchEnabled;
/**
+ * Can user change a sample category of the selected species batch ?
+ *
+ * @since 2.6
+ */
+ protected boolean changeSampleCategoryEnabled;
+
+ /**
* Can user remove a selected species batch?
*
* @since 0.3
@@ -313,6 +322,15 @@
firePropertyChange(PROPERTY_SPLIT_BATCH_ENABLED, null, splitBatchEnabled);
}
+ public boolean isChangeSampleCategoryEnabled() {
+ return changeSampleCategoryEnabled;
+ }
+
+ public void setChangeSampleCategoryEnabled(boolean changeSampleCategoryEnabled) {
+ this.changeSampleCategoryEnabled = changeSampleCategoryEnabled;
+ firePropertyChange(PROPERTY_CHANGE_SAMPLE_CATEGORY_ENABLED, null, changeSampleCategoryEnabled);
+ }
+
public boolean isRemoveBatchEnabled() {
return removeBatchEnabled;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -475,6 +475,15 @@
}
@Override
+ public void setSampleCategoryValue(Integer sampleCategoryId, Serializable value) {
+ SampleCategory<?> sampleCategory =
+ getSampleCategoryById(sampleCategoryId);
+ TuttiUIUtil.setProperty(sampleCategory,
+ SampleCategory.PROPERTY_CATEGORY_VALUE, value);
+ firePropertyChange(PROPERTY_SAMPLE_CATEGORY_VALUE, null, sampleCategory);
+ }
+
+ @Override
public void setSampleCategoryWeight(Integer sampleCategoryId, Object value) {
SampleCategory<?> sampleCategory =
getSampleCategoryById(sampleCategoryId);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -37,6 +37,7 @@
import org.jdesktop.swingx.table.TableColumnModelExt;
import javax.swing.table.TableColumn;
+import java.io.Serializable;
import java.util.Enumeration;
import java.util.Set;
@@ -170,19 +171,9 @@
log.debug("First ancestor row: " + firstRowIndex);
}
- // must save this row now
+ // save this row and his shell
+ updateShell(firstAncestor, columnIndex);
- // get shell of the ancestor
- Set<SpeciesBatchRowModel> shell = Sets.newHashSet();
- firstAncestor.collectShell(shell);
-
- for (SpeciesBatchRowModel batchRowModel : shell) {
- int currentRowIndex = getRowIndex(batchRowModel);
- if (log.isDebugEnabled()) {
- log.debug("Update shell row: " + currentRowIndex);
- }
- fireTableCellUpdated(currentRowIndex, columnIndex);
- }
} else {
super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry);
}
@@ -252,4 +243,65 @@
}
return result;
}
+
+ /**
+ * Return the sample category id of a column or {@code null} if not on a
+ * sample category column.
+ *
+ * @param columnIndex index of the column to look at
+ * @return the sample category id of a column or {@code null} if not on a
+ * sample category column.
+ * @since 2.6
+ */
+ public Integer getSampleCategoryId(int columnIndex) {
+ Integer result = null;
+ ColumnIdentifier<SpeciesBatchRowModel> identifier = getIdentifier(columnIndex);
+ if (sampleCols.contains(identifier)) {
+ SampleCategoryColumnIdentifier<SpeciesBatchRowModel> sampleId = (SampleCategoryColumnIdentifier<SpeciesBatchRowModel>) identifier;
+ result = sampleId.getSampleCategoryId();
+ }
+ return result;
+ }
+
+ /**
+ * Update the sample category value of all childs of the given {@code row}.
+ *
+ * @param row the row to walk through
+ * @param columnIndex index of the column where the sample category is
+ * @param newValue new sample category value to set
+ * @since 2.6
+ */
+ public void updateSampleCategorieValue(SpeciesBatchRowModel row,
+ int sampleCategoryId,
+ int columnIndex,
+ Serializable newValue) {
+
+ SampleCategoryColumnIdentifier<SpeciesBatchRowModel> identifier =
+ (SampleCategoryColumnIdentifier<SpeciesBatchRowModel>) getIdentifier(columnIndex);
+
+ // get the first ancestor using the category to update
+ SampleCategory<?> sampleCategory = row.getSampleCategoryById(sampleCategoryId);
+ SpeciesBatchRowModel firstAncestor = row.getFirstAncestor(sampleCategory);
+
+ // set category value
+ identifier.setCategoryValue(firstAncestor, newValue);
+
+ // update row shell
+ updateShell(firstAncestor, columnIndex);
+ }
+
+ protected void updateShell(SpeciesBatchRowModel entry, int columnIndex) {
+
+ Set<SpeciesBatchRowModel> shell = Sets.newHashSet();
+ entry.collectShell(shell);
+ shell.add(entry);
+
+ for (SpeciesBatchRowModel batchRowModel : shell) {
+ int currentRowIndex = getRowIndex(batchRowModel);
+ if (log.isDebugEnabled()) {
+ log.debug("Update shell row: " + currentRowIndex);
+ }
+ fireTableCellUpdated(currentRowIndex, columnIndex);
+ }
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-09-25 07:22:58 UTC (rev 1221)
@@ -162,6 +162,15 @@
_help: {"tutti.editSpeciesBatch.action.splitBatch.help"};
}
+#changeSampleCategoryMenu {
+ actionIcon: batch-split;
+ text: "tutti.editSpeciesBatch.action.changeSampleCategory";
+ toolTipText: "tutti.editSpeciesBatch.action.changeSampleCategory.tip";
+ i18nMnemonic: "tutti.editSpeciesBatch.action.changeSampleCategory.mnemonic";
+ enabled: {model.isTableViewModeAll() && model.isChangeSampleCategoryEnabled()};
+ _help: {"tutti.editSpeciesBatch.action.changeSampleCategory.help"};
+}
+
#removeSpeciesBatchMenu {
actionIcon: batch-delete;
text: "tutti.editSpeciesBatch.action.removeBatch";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-09-25 07:22:58 UTC (rev 1221)
@@ -78,6 +78,8 @@
<JPopupMenu id='tablePopup'>
<JMenuItem id='splitSpeciesBatchMenu'
onActionPerformed='handler.splitBatch()'/>
+ <JMenuItem id='changeSampleCategoryMenu'
+ onActionPerformed='handler.changeBatchCategory()'/>
<JMenuItem id='removeSpeciesBatchMenu'/>
<JMenuItem id='removeSpeciesSubBatchMenu'/>
<JMenuItem id='renameSpeciesBatchMenu'/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -26,6 +26,7 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
@@ -36,6 +37,7 @@
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocols;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.DecoratorService;
@@ -54,6 +56,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUI;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import fr.ifremer.tutti.ui.swing.util.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.WeightUnit;
import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellEditor;
@@ -66,6 +69,8 @@
import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.editor.NumberEditor;
+import jaxx.runtime.swing.renderer.DecoratorListCellRenderer;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
@@ -81,6 +86,7 @@
import org.nuiton.decorator.Decorator;
import org.nuiton.validator.NuitonValidatorResult;
+import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.RowFilter;
@@ -247,7 +253,6 @@
}
model.setRows(rows);
- recomputeBatchActionEnable();
}
//------------------------------------------------------------------------//
@@ -321,9 +326,6 @@
}
saveRow(firstAncestorRow);
- // when row valid state has changed, recompute action enabled states
- recomputeBatchActionEnable();
-
cleanrRowMonitor();
return;
@@ -334,9 +336,6 @@
}
saveSelectedRowIfNeeded();
-
- // when row valid state has changed, recompute action enabled states
- recomputeBatchActionEnable();
}
@Override
@@ -381,28 +380,6 @@
}
@Override
- protected void onRowValidStateChanged(int rowIndex,
- SpeciesBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- super.onRowValidStateChanged(rowIndex, row, oldValue, newValue);
-
- // when row valid state has changed, recompute action enabled states
- recomputeBatchActionEnable();
- }
-
- @Override
- protected void onAfterSelectedRowChanged(int oldRowIndex,
- SpeciesBatchRowModel oldRow,
- int newRowIndex,
- SpeciesBatchRowModel newRow) {
- super.onAfterSelectedRowChanged(oldRowIndex, oldRow, newRowIndex, newRow);
-
- // when selected row has changed, recompute action enabled states
- recomputeBatchActionEnable();
- }
-
- @Override
protected void addHighlighters(JXTable table) {
super.addHighlighters(table);
@@ -475,6 +452,163 @@
table.addHighlighter(attachmentHighlighter);
}
+ @Override
+ protected void beforeOpenPopup(int rowIndex, int columnIndex) {
+ super.beforeOpenPopup(rowIndex, columnIndex);
+
+ boolean enableAdd = true;
+
+ boolean enableRename = false;
+ boolean enableSplit = false;
+ boolean enableChangeSampleCategory = false;
+ boolean enableRemove = false;
+ boolean enableRemoveSub = false;
+ boolean enableCreateMelag = false;
+ boolean enableEditFrequencies = false;
+
+ if (rowIndex != -1) {
+
+ // there is a selected row
+
+
+ //TODO If there is some sub-batch, can remove them
+ //TODO If there is no sub-batch, can split current batch
+
+ SpeciesBatchTableModel tableModel = getTableModel();
+ SpeciesBatchRowModel row = tableModel.getEntry(rowIndex);
+ int selectedRowCount = getTable().getSelectedRowCount();
+
+ // can edit frequencies on a single selected leaf row
+
+
+ enableSplit = true;
+
+ // action with single selection
+ enableRemove = selectedRowCount == 1;
+ enableRemoveSub = selectedRowCount == 1;
+ enableRename = selectedRowCount == 1;
+ enableCreateMelag = selectedRowCount > 1;
+ enableEditFrequencies = selectedRowCount == 1;
+ enableChangeSampleCategory = selectedRowCount == 1 && tableModel.isCellEditable(rowIndex, columnIndex);
+
+ if (enableSplit) {
+
+ // can split if selected batch is a leaf
+
+ Integer lastSamplingId = sampleCategoryModel.getLastCategoryId();
+
+ enableSplit = row.isBatchLeaf()
+ && selectedRowCount == 1
+ && ObjectUtils.notEqual(lastSamplingId, row.getFinestCategory().getCategoryId())
+ && row.getNumber() == null
+ && (row.getComputedNumber() == null
+ || row.getComputedNumber() == 0);
+ }
+
+ if (enableChangeSampleCategory) {
+
+ // can change category if there is still a brother category free
+ Integer sampleCategoryId =
+ tableModel.getSampleCategoryId(columnIndex);
+
+ if (sampleCategoryId == null) {
+
+ // not on a sample category column
+ enableChangeSampleCategory = false;
+ } else {
+
+ // get category
+ SampleCategoryModelEntry category =
+ sampleCategoryModel.getCategoryById(sampleCategoryId);
+
+ // get all used values for this category
+ Set<Serializable> used = getSampleUsedValues(
+ row, sampleCategoryId);
+
+ if (category.getCaracteristic().isNumericType()) {
+
+ // if number then can always change it
+
+ } else {
+
+ // get all possible values
+
+ List<CaracteristicQualitativeValue> available =
+ Lists.newArrayList(category.getCaracteristic().getQualitativeValue());
+ available.removeAll(used);
+
+ // action possible only if there is still some available values
+ enableChangeSampleCategory = !available.isEmpty();
+ }
+ }
+
+ }
+
+ if (enableEditFrequencies) {
+
+ // can edit frequencies only on a leaf
+ enableEditFrequencies = row.isBatchLeaf();
+ }
+
+ if (enableRename) {
+
+ // can rename if selected batch is a parent
+ enableRename = row.isBatchRoot();
+ }
+
+ if (enableRemove) {
+
+ // can always remove the batch
+ // no more test
+ }
+
+ if (enableRemoveSub) {
+
+ // can remove sub batch if selected batch is not a leaf
+ enableRemoveSub = !row.isBatchLeaf();
+ }
+
+ if (enableCreateMelag) {
+
+ JXTable table = getTable();
+
+ // can add species to a melag if several root are selected
+ int[] selectedRows = table.getSelectedRows();
+ for (int selectedRowIndex : selectedRows) {
+ SpeciesBatchRowModel selectedRow =
+ tableModel.getEntry(selectedRowIndex);
+
+ if (!selectedRow.isBatchRoot()) {
+ enableCreateMelag = false;
+ break;
+ }
+ }
+ }
+ }
+ SpeciesBatchUIModel model = getModel();
+ model.setCreateBatchEnabled(enableAdd);
+ model.setSplitBatchEnabled(enableSplit);
+ model.setChangeSampleCategoryEnabled(enableChangeSampleCategory);
+ model.setRemoveBatchEnabled(enableRemove);
+ model.setRemoveSubBatchEnabled(enableRemoveSub);
+ model.setRenameBatchEnabled(enableRename);
+ model.setCreateMelagEnabled(enableCreateMelag);
+ model.setEditFrequenciesEnabled(enableEditFrequencies);
+
+ if (log.isInfoEnabled()) {
+ StringBuilder builder = new StringBuilder("actions for (" + rowIndex + "," + columnIndex + "):");
+ builder.append("\nenableAdd: ").append(enableAdd);
+ builder.append("\nenableSplit: ").append(enableSplit);
+ builder.append("\nenableChangeSampleCategory: ").append(enableChangeSampleCategory);
+ builder.append("\nenableRemove: ").append(enableRemove);
+ builder.append("\nenableRemoveSub: ").append(enableRemoveSub);
+ builder.append("\nenableRename: ").append(enableRename);
+ builder.append("\nenableCreateMelag: ").append(enableCreateMelag);
+ builder.append("\nenableEditFrequencies: ").append(enableEditFrequencies);
+ log.info(builder.toString());
+ }
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@@ -625,8 +759,6 @@
getTable().setRowFilter(filter);
}
});
-
- recomputeBatchActionEnable();
}
@Override
@@ -689,8 +821,6 @@
);
}
}
-
- recomputeBatchActionEnable();
}
public void editFrequencies() {
@@ -757,6 +887,107 @@
}
}
+ public void changeBatchCategory() {
+
+ // get table model
+ SpeciesBatchTableModel tableModel = getTableModel();
+
+ // get selected row
+ int rowIndex = getTable().getSelectedRow();
+
+ // get selected column
+ int columnIndex = getTable().getSelectedColumn();
+
+ // get selected row
+ SpeciesBatchRowModel selectedRow = tableModel.getEntry(rowIndex);
+
+ // get his sample category
+ Integer sampleCategoryId = tableModel.getSampleCategoryId(columnIndex);
+ SampleCategoryModelEntry sampleCategory = sampleCategoryModel.getCategoryById(sampleCategoryId);
+ Caracteristic caracteristic = sampleCategory.getCaracteristic();
+
+ // get used values
+ Set<Serializable> usedValues = getSampleUsedValues(selectedRow,
+ sampleCategoryId);
+
+ // get the new selected value for this category
+ Serializable selectedItem;
+
+ String categoryDecorated = decorate(caracteristic, DecoratorService.CARACTERISTIC_PARAMETER_ONLY);
+ String dialogTitle = _("tutti.editSpeciesBatch.title.changeSampleCategoryValue", categoryDecorated);
+
+ if (caracteristic.isNumericType()) {
+
+ // open a simple number editor
+ NumberEditor editor = new NumberEditor();
+ editor.setNumberPattern(TuttiUI.DECIMAL3_PATTERN);
+ editor.setUseSign(false);
+ editor.setUseFloat(true);
+ editor.setShowPopupButton(false);
+ editor.setShowReset(false);
+
+ int response = JOptionPane.showConfirmDialog(
+ getUI(),
+ editor,
+ dialogTitle,
+ JOptionPane.OK_CANCEL_OPTION);
+
+ if (response == JOptionPane.OK_OPTION) {
+ selectedItem = editor.getModel();
+ } else {
+ // user cancel selection
+ selectedItem = null;
+ }
+
+ if (usedValues.contains(selectedItem)) {
+
+ // impossible de choisir cette valeur (déjà utilisée)
+ JOptionPane.showMessageDialog(
+ getTopestUI(),
+ _("tutti.editSpeciesBatch.error.sampleCategoryValue.notAvailable", selectedItem, categoryDecorated));
+ selectedItem = null;
+ }
+
+ } else {
+
+ // open a combobox to select new value
+
+ List<CaracteristicQualitativeValue> availableValues =
+ Lists.newArrayList(caracteristic.getQualitativeValue());
+ availableValues.removeAll(usedValues);
+
+ JComboBox editor = new JComboBox();
+ editor.setRenderer(new DecoratorListCellRenderer(getDecorator(CaracteristicQualitativeValue.class, null)));
+ SwingUtil.fillComboBox(editor, availableValues, availableValues.get(0));
+
+ int response = JOptionPane.showConfirmDialog(
+ getTopestUI(),
+ editor,
+ dialogTitle,
+ JOptionPane.OK_CANCEL_OPTION);
+
+ if (response == JOptionPane.OK_OPTION) {
+ selectedItem = (CaracteristicQualitativeValue) editor.getSelectedItem();
+ } else {
+ // user cancel selection
+ selectedItem = null;
+ }
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("New selected category: " + selectedItem);
+ }
+
+ if (selectedItem != null) {
+
+ // update rows values
+ tableModel.updateSampleCategorieValue(selectedRow,
+ sampleCategoryId,
+ columnIndex,
+ selectedItem);
+ }
+ }
+
public void splitBatch(SampleCategoryModelEntry sampleCategoryDef,
List<SplitSpeciesBatchRowModel> rows,
Float totalRowWeight) {
@@ -808,8 +1039,6 @@
SpeciesBatchUIModel model = getModel();
model.setLeafNumber(model.getLeafNumber() + newBatches.size() - 1);
-
- recomputeBatchActionEnable();
}
public void updateTotalFromFrequencies(SpeciesBatchRowModel row) {
@@ -827,8 +1056,6 @@
}
row.setComputedNumber(totalNumber);
row.getFinestCategory().setOnlyOneFrequency(onlyOneFrequency);
-
- recomputeBatchActionEnable();
}
public void saveRows(Iterable<SpeciesBatchRowModel> rows) {
@@ -838,188 +1065,10 @@
}
}
- protected void saveRow(SpeciesBatchRowModel row) {
-
- FishingOperation fishingOperation = getModel().getFishingOperation();
- Preconditions.checkNotNull(fishingOperation);
-
- Preconditions.checkNotNull(row.getSpecies());
- SampleCategory<?> sampleCategory = row.getFinestCategory();
- Preconditions.checkNotNull(sampleCategory);
- Preconditions.checkNotNull(sampleCategory.getCategoryId());
- Preconditions.checkNotNull(sampleCategory.getCategoryValue());
-
- SpeciesBatch catchBean = row.toBean();
-
- // convert weight
- Float weight = catchBean.getWeight();
- catchBean.setWeight(weightUnit.toEntity(weight));
-
- catchBean.setFishingOperation(fishingOperation);
-
- SpeciesBatchRowModel parent = row.getParentBatch();
- if (parent != null) {
- //FIXME Check no need to convert parent weight ? :(
- catchBean.setParentBatch(parent.toBean());
- }
-
- // apply sample category
- catchBean.setSampleCategoryId(sampleCategory.getCategoryId());
- catchBean.setSampleCategoryValue(sampleCategory.getCategoryValue());
-
- // convert sample category weight
- Float categoryWeight = sampleCategory.getCategoryWeight();
- catchBean.setSampleCategoryWeight(weightUnit.toEntity(categoryWeight));
-
- if (TuttiEntities.isNew(catchBean)) {
-
- String parentBatchId = null;
- if (parent != null) {
- parentBatchId = parent.getId();
- }
-
- if (log.isInfoEnabled()) {
- log.info("Persist new species batch with parentId: " +
- parentBatchId);
- }
- catchBean = persistenceService.createSpeciesBatch(catchBean,
- parentBatchId);
- row.setId(catchBean.getId());
- } else {
- if (log.isInfoEnabled()) {
- log.info("Persist existing species batch: " + catchBean.getId() + " (parent : " + catchBean.getParentBatch() + ")");
- }
- persistenceService.saveSpeciesBatch(catchBean);
- }
-
- List<SpeciesFrequencyRowModel> frequencyRows = row.getFrequency();
-
- List<SpeciesBatchFrequency> frequency =
- SpeciesFrequencyRowModel.toEntity(
- frequencyRows,
- catchBean);
-
- if (log.isInfoEnabled()) {
- log.info("Will save " + frequency.size() + " frequencies.");
- }
- frequency = persistenceService.saveSpeciesBatchFrequency(
- catchBean.getId(), frequency);
-
- // push it back to row model
- frequencyRows = SpeciesFrequencyRowModel.fromEntity(weightUnit,
- frequency);
- row.setFrequency(frequencyRows);
-
- getModel().fireBatchUpdated(row);
- }
-
public String getFilterSpeciesBatchRootButtonText(int rootNumber) {
return _("tutti.editSpeciesBatch.filterBatch.mode.root", rootNumber);
}
- protected void recomputeBatchActionEnable() {
-
- int rowIndex = getTable().getSelectedRow();
-
- //TODO Improve this test
- boolean enableAdd = true;
-
- boolean enableRename = false;
- boolean enableSplit = false;
- boolean enableRemove = false;
- boolean enableRemoveSub = false;
- boolean enableCreateMelag = false;
- boolean enableEditFrequencies = false;
-
- if (rowIndex != -1) {
-
- // there is a selected row
-
-
- //TODO If there is some sub-batch, can remove them
- //TODO If there is no sub-batch, can split current batch
-
- SpeciesBatchTableModel tableModel = getTableModel();
- SpeciesBatchRowModel row = tableModel.getEntry(rowIndex);
- int selectedRowCount = getTable().getSelectedRowCount();
-
- // can edit frequencies on a single selected leaf row
-
-
- enableSplit = true;
-
- // action with single selection
- enableRemove = selectedRowCount == 1;
- enableRemoveSub = selectedRowCount == 1;
- enableRename = selectedRowCount == 1;
- enableCreateMelag = selectedRowCount > 1;
- enableEditFrequencies = selectedRowCount == 1;
-
- if (enableSplit) {
-
- // can split if selected batch is a leaf
- Integer lastSamplingId = sampleCategoryModel.getLastCategoryId();
-
- enableSplit = row.isBatchLeaf()
- && selectedRowCount == 1
- && ObjectUtils.notEqual(lastSamplingId, row.getFinestCategory().getCategoryId())
- && row.getNumber() == null
- && (row.getComputedNumber() == null
- || row.getComputedNumber() == 0);
- }
-
- if (enableEditFrequencies) {
-
- // can edit frequencies only on a leaf
- enableEditFrequencies = row.isBatchLeaf();
- }
-
- if (enableRename) {
-
- // can rename if selected batch is a parent
- enableRename = row.isBatchRoot();
- }
-
- if (enableRemove) {
-
- // can always remove the batch
- // no more test
- }
-
- if (enableRemoveSub) {
-
- // can remove sub batch if selected batch is not a leaf
- enableRemoveSub = !row.isBatchLeaf();
- }
-
- if (enableCreateMelag) {
-
- JXTable table = getTable();
-
- // can add species to a melag if several root are selected
- int[] selectedRows = table.getSelectedRows();
- for (int selectedRowIndex : selectedRows) {
- SpeciesBatchRowModel selectedRow =
- tableModel.getEntry(selectedRowIndex);
-
- if (!selectedRow.isBatchRoot()) {
- enableCreateMelag = false;
- break;
- }
- }
- }
- }
-
- SpeciesBatchUIModel model = getModel();
- model.setCreateBatchEnabled(enableAdd);
- model.setSplitBatchEnabled(enableSplit);
- model.setRemoveBatchEnabled(enableRemove);
- model.setRemoveSubBatchEnabled(enableRemoveSub);
- model.setRenameBatchEnabled(enableRename);
- model.setCreateMelagEnabled(enableCreateMelag);
- model.setEditFrequenciesEnabled(enableEditFrequencies);
- }
-
public void collectChildren(SpeciesBatchRowModel row,
Set<SpeciesBatchRowModel> collectedRows) {
@@ -1114,6 +1163,113 @@
return newRow;
}
+ public void removeFromSpeciesUsed(SpeciesBatchRowModel row) {
+ Preconditions.checkNotNull(row);
+ Preconditions.checkNotNull(row.getSpecies());
+ SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
+ CaracteristicQualitativeValue categoryValue = (CaracteristicQualitativeValue) firstSampleCategory.getCategoryValue();
+ Preconditions.checkNotNull(firstSampleCategory);
+ if (log.isInfoEnabled()) {
+ log.info("Remove from speciesUsed: " + decorate(categoryValue) + " - " + decorate(row.getSpecies()));
+ }
+ SpeciesBatchUIModel model = getModel();
+ model.getSpeciesUsed().remove(categoryValue, row.getSpecies());
+
+ if (row.isBatchRoot()) {
+ model.setRootNumber(model.getRootNumber() - 1);
+ }
+ }
+
+ public Species openAddSpeciesDialog(String title, List<Species> species) {
+ SelectSpeciesUI dialogContent = new SelectSpeciesUI(ui);
+ SelectSpeciesUIModel model = dialogContent.getModel();
+ model.setSelectedSpecies(null);
+ model.setSpecies(species);
+
+ openDialog(dialogContent, title, new Dimension(400, 130));
+
+ return model.getSelectedSpecies();
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected void saveRow(SpeciesBatchRowModel row) {
+
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ Preconditions.checkNotNull(fishingOperation);
+
+ Preconditions.checkNotNull(row.getSpecies());
+ SampleCategory<?> sampleCategory = row.getFinestCategory();
+ Preconditions.checkNotNull(sampleCategory);
+ Preconditions.checkNotNull(sampleCategory.getCategoryId());
+ Preconditions.checkNotNull(sampleCategory.getCategoryValue());
+
+ SpeciesBatch catchBean = row.toBean();
+
+ // convert weight
+ Float weight = catchBean.getWeight();
+ catchBean.setWeight(weightUnit.toEntity(weight));
+
+ catchBean.setFishingOperation(fishingOperation);
+
+ SpeciesBatchRowModel parent = row.getParentBatch();
+ if (parent != null) {
+ //FIXME Check no need to convert parent weight ? :(
+ catchBean.setParentBatch(parent.toBean());
+ }
+
+ // apply sample category
+ catchBean.setSampleCategoryId(sampleCategory.getCategoryId());
+ catchBean.setSampleCategoryValue(sampleCategory.getCategoryValue());
+
+ // convert sample category weight
+ Float categoryWeight = sampleCategory.getCategoryWeight();
+ catchBean.setSampleCategoryWeight(weightUnit.toEntity(categoryWeight));
+
+ if (TuttiEntities.isNew(catchBean)) {
+
+ String parentBatchId = null;
+ if (parent != null) {
+ parentBatchId = parent.getId();
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("Persist new species batch with parentId: " +
+ parentBatchId);
+ }
+ catchBean = persistenceService.createSpeciesBatch(catchBean,
+ parentBatchId);
+ row.setId(catchBean.getId());
+ } else {
+ if (log.isInfoEnabled()) {
+ log.info("Persist existing species batch: " + catchBean.getId() + " (parent : " + catchBean.getParentBatch() + ")");
+ }
+ persistenceService.saveSpeciesBatch(catchBean);
+ }
+
+ List<SpeciesFrequencyRowModel> frequencyRows = row.getFrequency();
+
+ List<SpeciesBatchFrequency> frequency =
+ SpeciesFrequencyRowModel.toEntity(
+ frequencyRows,
+ catchBean);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will save " + frequency.size() + " frequencies.");
+ }
+ frequency = persistenceService.saveSpeciesBatchFrequency(
+ catchBean.getId(), frequency);
+
+ // push it back to row model
+ frequencyRows = SpeciesFrequencyRowModel.fromEntity(weightUnit,
+ frequency);
+ row.setFrequency(frequencyRows);
+
+ getModel().fireBatchUpdated(row);
+ }
+
protected void loadBatchRow(SpeciesBatchRowModel parentRow,
SpeciesBatchRowModel newRow,
Integer sampleCategoryId,
@@ -1161,29 +1317,11 @@
SampleCategoryComponent.newEditor(decorator, weightUnit),
SampleCategoryComponent.newRender(defaultRenderer,
decorator,
- getConfig().getColorComputedWeights()
- ),
+ getConfig().getColorComputedWeights()),
columnIdentifier,
weightUnit);
}
- public void removeFromSpeciesUsed(SpeciesBatchRowModel row) {
- Preconditions.checkNotNull(row);
- Preconditions.checkNotNull(row.getSpecies());
- SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
- CaracteristicQualitativeValue categoryValue = (CaracteristicQualitativeValue) firstSampleCategory.getCategoryValue();
- Preconditions.checkNotNull(firstSampleCategory);
- if (log.isInfoEnabled()) {
- log.info("Remove from speciesUsed: " + decorate(categoryValue) + " - " + decorate(row.getSpecies()));
- }
- SpeciesBatchUIModel model = getModel();
- model.getSpeciesUsed().remove(categoryValue, row.getSpecies());
-
- if (row.isBatchRoot()) {
- model.setRootNumber(model.getRootNumber() - 1);
- }
- }
-
protected void addToSpeciesUsed(SpeciesBatchRowModel row) {
Preconditions.checkNotNull(row);
Preconditions.checkNotNull(row.getSpecies());
@@ -1201,38 +1339,14 @@
model.setRootNumber(model.getRootNumber() + 1);
}
- public Species openAddSpeciesDialog(String title, List<Species> species) {
- SelectSpeciesUI dialogContent = new SelectSpeciesUI(ui);
- SelectSpeciesUIModel model = dialogContent.getModel();
- model.setSelectedSpecies(null);
- model.setSpecies(species);
-
- openDialog(dialogContent, title, new Dimension(400, 130));
-
- return model.getSelectedSpecies();
- }
-
protected SpeciesBatch convertRowToEntity(SpeciesBatchRowModel row,
boolean convertParent) {
Preconditions.checkNotNull(row.getFinestCategory());
Preconditions.checkNotNull(row.getFinestCategory().getCategoryId());
Preconditions.checkNotNull(row.getFinestCategory().getCategoryValue());
-// SampleCategory<?> sampleCategory = row.getFinestCategory();
-// Preconditions.checkNotNull(sampleCategory);
-// Preconditions.checkNotNull(sampleCategory.getCategoryId());
-// Preconditions.checkNotNull(sampleCategory.getCategoryValue());
-
SpeciesBatch catchBean = row.toEntity();
-// // apply sample category
-// catchBean.setSampleCategoryId(sampleCategory.getCategoryId());
-// catchBean.setSampleCategoryValue(sampleCategory.getCategoryValue());
-//
-// // convert sample category weight
-// Float categoryWeight = sampleCategory.getCategoryWeight();
-// catchBean.setSampleCategoryWeight(weightUnit.toEntity(categoryWeight));
-
if (convertParent && row.getParentBatch() != null) {
SpeciesBatch parent = convertRowToEntity(row.getParentBatch(), true);
catchBean.setParentBatch(parent);
@@ -1240,4 +1354,45 @@
return catchBean;
}
+
+ /**
+ * Return all the sample category values (of the given
+ * {@code sampleCategoryId}) for all brothers of the given {@code row}.
+ *
+ * @param row the row
+ * @param sampleCategoryId id of the sample category to seek in brothers of the given row
+ * @return all the sample category values (of the given
+ * {@code sampleCategoryId}) for all brothers of the given {@code row}.
+ */
+ protected Set<Serializable> getSampleUsedValues(SpeciesBatchRowModel row,
+ int sampleCategoryId) {
+
+ // get the first ancestor for the sample category
+ SampleCategory<?> sampleCategory = row.getSampleCategoryById(sampleCategoryId);
+ SpeciesBatchRowModel firstAncestor = row.getFirstAncestor(sampleCategory);
+
+ Set<Serializable> usedValues = Sets.newHashSet();
+ List<SpeciesBatchRowModel> childs;
+ if (firstAncestor.isBatchRoot()) {
+
+ // on a root must take all his brothers (but have no common ancestor...)
+ Species species = firstAncestor.getSpecies();
+ childs = Lists.newArrayList();
+ for (SpeciesBatchRowModel rowToScan : getModel().getRows()) {
+ if (rowToScan.isBatchRoot() && species.equals(rowToScan.getSpecies())) {
+ childs.add(rowToScan);
+ }
+ }
+ } else {
+ // on a son, must take all the brother directly from his father
+ SpeciesBatchRowModel parentBatch = firstAncestor.getParentBatch();
+ childs = parentBatch.getChildBatch();
+ }
+
+ for (SpeciesBatchRowModel child : childs) {
+ SampleCategory<?> category = child.getSampleCategoryById(sampleCategoryId);
+ usedValues.add(category.getCategoryValue());
+ }
+ return usedValues;
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -49,6 +49,8 @@
public static final String PROPERTY_SPLIT_BATCH_ENABLED = "splitBatchEnabled";
+ public static final String PROPERTY_CHANGE_SAMPLE_CATEGORY_ENABLED = "changeSampleCategoryEnabled";
+
public static final String PROPERTY_REMOVE_SUB_BATCH_ENABLED = "removeSubBatchEnabled";
public static final String PROPERTY_RENAME_BATCH_ENABLED = "renameBatchEnabled";
@@ -86,6 +88,13 @@
protected boolean splitBatchEnabled;
/**
+ * Can user change a sample category of the selected species batch ?
+ *
+ * @since 2.6
+ */
+ protected boolean changeSampleCategoryEnabled;
+
+ /**
* Can user remove a selected species batch?
*
* @since 0.3
@@ -295,6 +304,15 @@
firePropertyChange(PROPERTY_SPLIT_BATCH_ENABLED, null, splitBatchEnabled);
}
+ public boolean isChangeSampleCategoryEnabled() {
+ return changeSampleCategoryEnabled;
+ }
+
+ public void setChangeSampleCategoryEnabled(boolean changeSampleCategoryEnabled) {
+ this.changeSampleCategoryEnabled = changeSampleCategoryEnabled;
+ firePropertyChange(PROPERTY_CHANGE_SAMPLE_CATEGORY_ENABLED, null, changeSampleCategoryEnabled);
+ }
+
public boolean isRemoveBatchEnabled() {
return removeBatchEnabled;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -1008,12 +1008,16 @@
JXTable source = (JXTable) e.getSource();
int[] selectedRows = source.getSelectedRows();
+ int[] selectedColumns = source.getSelectedColumns();
// get the row index at this point
int rowIndex = source.rowAtPoint(p);
+ // get the column index at this point
+ int columnIndex = source.columnAtPoint(p);
+
if (log.isDebugEnabled()) {
- log.debug("At point [" + p + "] found Row " + rowIndex);
+ log.debug("At point [" + p + "] found Row " + rowIndex + ", Column " + columnIndex);
}
boolean canContinue = true;
@@ -1039,8 +1043,17 @@
source.setRowSelectionInterval(rowIndex, rowIndex);
}
+ // select column (could empty selection)
+ if (columnIndex == -1) {
+ source.clearSelection();
+ } else if (!ArrayUtils.contains(selectedColumns, columnIndex)) {
+ source.setColumnSelectionInterval(columnIndex, columnIndex);
+ }
+
if (rightClick) {
+ beforeOpenPopup(rowIndex, columnIndex);
+
// on right click show popup
popup.show(source, e.getX(), e.getY());
}
@@ -1048,6 +1061,20 @@
}
}
+ /**
+ * Hook to prepare popup just before showing it.
+ * <p/>
+ * The right place to update actions accessibility; a quite better design
+ * than trying to update each time something change in the table...
+ *
+ * @param rowIndex selected row index (or lowest selected one)
+ * @param columnIndex selected column index
+ * @since 2.6
+ */
+ protected void beforeOpenPopup(int rowIndex, int columnIndex) {
+
+ }
+
public void openRowMenu(KeyEvent e, JPopupMenu popup) {
if (e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU) {
@@ -1061,7 +1088,8 @@
lowestRow = Math.max(lowestRow, row);
}
// get the selected column
- Rectangle r = source.getCellRect(lowestRow, source.getSelectedColumn(), true);
+ int selectedColumn = source.getSelectedColumn();
+ Rectangle r = source.getCellRect(lowestRow, selectedColumn, true);
// get the point in the middle lower of the cell
Point p = new Point(r.x + r.width / 2, r.y + r.height);
@@ -1085,6 +1113,9 @@
}
if (canContinue) {
+
+ beforeOpenPopup(lowestRow, selectedColumn);
+
popup.show(source, p.x, p.y);
}
}
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-09-25 07:22:58 UTC (rev 1221)
@@ -352,6 +352,9 @@
tutti.editAccidentalBatch.table.header.species.tip=
tutti.editAccidentalBatch.table.header.weight=
tutti.editAccidentalBatch.table.header.weight.tip=
+tutti.editBenthosBatch.action.changeSampleCategory=
+tutti.editBenthosBatch.action.changeSampleCategory.mnemonic=
+tutti.editBenthosBatch.action.changeSampleCategory.tip=
tutti.editBenthosBatch.action.createBatch=
tutti.editBenthosBatch.action.createBatch.mnemonic=
tutti.editBenthosBatch.action.createBatch.tip=
@@ -389,6 +392,7 @@
tutti.editBenthosBatch.action.splitBatch=
tutti.editBenthosBatch.action.splitBatch.mnemonic=
tutti.editBenthosBatch.action.splitBatch.tip=
+tutti.editBenthosBatch.error.sampleCategoryValue.notAvailable=
tutti.editBenthosBatch.field.benthosTotalInertWeight=
tutti.editBenthosBatch.field.benthosTotalInertWeight.tip=
tutti.editBenthosBatch.field.benthosTotalLivingNotItemizedWeight=
@@ -424,6 +428,7 @@
tutti.editBenthosBatch.table.header.toConfirm.tip=
tutti.editBenthosBatch.table.header.weight=
tutti.editBenthosBatch.table.header.weight.tip=
+tutti.editBenthosBatch.title.changeSampleCategoryValue=
tutti.editBenthosFrequencies.action.cancel=
tutti.editBenthosFrequencies.action.cancel.mnemonic=
tutti.editBenthosFrequencies.action.cancel.tip=
@@ -868,6 +873,9 @@
tutti.editSampleCategoryModel.table.header.label=
tutti.editSampleCategoryModel.table.header.label.tip=
tutti.editSampleCategoryModel.title=
+tutti.editSpeciesBatch.action.changeSampleCategory=
+tutti.editSpeciesBatch.action.changeSampleCategory.mnemonic=
+tutti.editSpeciesBatch.action.changeSampleCategory.tip=
tutti.editSpeciesBatch.action.createBatch=
tutti.editSpeciesBatch.action.createBatch.mnemonic=
tutti.editSpeciesBatch.action.createBatch.tip=
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-09-25 07:22:58 UTC (rev 1221)
@@ -351,6 +351,9 @@
tutti.editAccidentalBatch.table.header.species.tip=Espèce
tutti.editAccidentalBatch.table.header.weight=Poids observé
tutti.editAccidentalBatch.table.header.weight.tip=Poids observé
+tutti.editBenthosBatch.action.changeSampleCategory=Modifier la catégorie
+tutti.editBenthosBatch.action.changeSampleCategory.mnemonic=M
+tutti.editBenthosBatch.action.changeSampleCategory.tip=Modifier la catégorie de la cellule sélectionnée
tutti.editBenthosBatch.action.createBatch=Créer un lot pour une espèce
tutti.editBenthosBatch.action.createBatch.mnemonic=C
tutti.editBenthosBatch.action.createBatch.tip=Créer un nouveau lot pour une espèce
@@ -388,6 +391,8 @@
tutti.editBenthosBatch.action.splitBatch=Catégoriser le lot
tutti.editBenthosBatch.action.splitBatch.mnemonic=C
tutti.editBenthosBatch.action.splitBatch.tip=Catégoriser le lot courant (celui de la ligne sélectionné)
+tutti.editBenthosBatch.error.sampleCategoryValue.notAvailable=La valeur %s de la catégorie %s est déjà utilisée
+tutti.editSpeciesBatch.error.sampleCategoryValue.notAvailable=La valeur %s de la catégorie %s est déjà utilisée
tutti.editBenthosBatch.field.benthosTotalInertWeight=Poids inerte trié
tutti.editBenthosBatch.field.benthosTotalInertWeight.tip=Poids de la fraction inerte restante après le tri du benthos (cailloux, vase, débris coquilliers, etc.)
tutti.editBenthosBatch.field.benthosTotalLivingNotItemizedWeight=Poids vivant non détaillé trié
@@ -423,12 +428,16 @@
tutti.editBenthosBatch.table.header.toConfirm.tip=Case à cocher si il y a un doute sur l'identification de l'espèce
tutti.editBenthosBatch.table.header.weight=Poids sous-échantillonné
tutti.editBenthosBatch.table.header.weight.tip=Poids du lot mesuré ou dénombré
+tutti.editBenthosBatch.title.changeSampleCategoryValue=Changer la valeur de la catégorie %s
+tutti.editSpeciesBatch.title.changeSampleCategoryValue=Changer la valeur de la catégorie %s
tutti.editBenthosFrequencies.action.cancel=Annuler
tutti.editBenthosFrequencies.action.cancel.mnemonic=A
tutti.editBenthosFrequencies.action.cancel.tip=Annuler l'édition des mensurations
tutti.editBenthosFrequencies.action.generate=Générer
tutti.editBenthosFrequencies.action.generate.mnemonic=G
tutti.editBenthosFrequencies.action.generate.tip=Générer les mensurations
+tutti.editBenthosFrequencies.action.reset=Réinitialiser
+tutti.editBenthosFrequencies.action.reset.tip=Supprimer toutes les mensurations saisies
tutti.editBenthosFrequencies.action.saveAndClose=Enregistrer et Fermer
tutti.editBenthosFrequencies.action.saveAndClose.mnemonic=F
tutti.editBenthosFrequencies.action.saveAndClose.tip=Enregistrer les mensurations
@@ -867,6 +876,9 @@
tutti.editSampleCategoryModel.table.header.label=Label
tutti.editSampleCategoryModel.table.header.label.tip=Label de la catéogire (sera utilisée dans les entêtes de tableau)
tutti.editSampleCategoryModel.title=Configurer les catégorisations
+tutti.editSpeciesBatch.action.changeSampleCategory=Modifier la catégorie
+tutti.editSpeciesBatch.action.changeSampleCategory.mnemonic=M
+tutti.editSpeciesBatch.action.changeSampleCategory.tip=Modifier la catégorie de la cellule sélectionnée
tutti.editSpeciesBatch.action.createBatch=Créer un lot pour une espèce
tutti.editSpeciesBatch.action.createBatch.mnemonic=C
tutti.editSpeciesBatch.action.createBatch.tip=Créer un nouveau lot pour une espèce
@@ -951,9 +963,6 @@
tutti.editSpeciesFrequencies.action.reset=Réinitialiser
tutti.editSpeciesFrequencies.action.reset.mnemonic=R
tutti.editSpeciesFrequencies.action.reset.tip=Supprimer toutes les mensurations saisies
-tutti.editBenthosFrequencies.action.reset=Réinitialiser
-tutti.editbenthosFrequencies.action.reset.mnemonic=R
-tutti.editBenthosFrequencies.action.reset.tip=Supprimer toutes les mensurations saisies
tutti.editSpeciesFrequencies.action.saveAndClose=Enregistrer et Fermer
tutti.editSpeciesFrequencies.action.saveAndClose.mnemonic=F
tutti.editSpeciesFrequencies.action.saveAndClose.tip=Enregistrer les mensurations
@@ -992,6 +1001,7 @@
tutti.editSpeciesFrequencies.table.header.number=Nombre
tutti.editSpeciesFrequencies.table.header.weight=Poids observé
tutti.editSpeciesFrequencies.title=Mensuration
+tutti.editbenthosFrequencies.action.reset.mnemonic=R
tutti.error.about.could.not.reach.url=Récupération des versions de mises à jour impossible (l'url <strong>%s</strong> n'est pas joignable)
tutti.error.delete.startActionFile=Impossible de supprimer le fichier %s
tutti.error.errorpane.htmlmessage=<html><body><b>Une erreur s'est produite</b>\:<br/>%s</body></html>
1
0
24 Sep '13
Author: tchemit
Date: 2013-09-24 17:43:28 +0200 (Tue, 24 Sep 2013)
New Revision: 1220
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1220
Log:
fixes #3344: [CAPTURE] harmoniser les racourcis Alt+C pour cr?\195?\169er et continuer dans esp?\195?\169ces et mensuration (actuellment Alt + E dans mensuration)
fixes #3322: [ERGO] cr?\195?\169er et continuer : mieux g?\195?\169rer l'?\195?\169cran entre quantification d'un lot et cat?\195?\169gorisation
fixes #3318: [MENSURATIONS] ajouter bouton "r?\195?\169initialiser" dans l'?\195?\169cran pour effacer toutes les classes de tailles et les nombres
refs #3359: [TECH] Updates jaxx to 2.5.27
Modified:
trunk/pom.xml
trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties
trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel-error-validation.xml
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel-error-validation.xml
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-09-24 13:30:43 UTC (rev 1219)
+++ trunk/pom.xml 2013-09-24 15:43:28 UTC (rev 1220)
@@ -131,7 +131,7 @@
<eugenePluginVersion>2.7</eugenePluginVersion>
<hibernateVersion>3.6.10.Final</hibernateVersion>
- <jaxxVersion>2.5.26</jaxxVersion>
+ <jaxxVersion>2.5.27-SNAPSHOT</jaxxVersion>
<swingXVersion>1.6.4</swingXVersion>
<xworkVersion>2.3.15.1</xworkVersion>
Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-09-24 13:30:43 UTC (rev 1219)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-09-24 15:43:28 UTC (rev 1220)
@@ -1,5 +1,5 @@
#Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo
-#Sun Sep 22 16:40:00 CEST 2013
+#Tue Sep 24 16:21:02 CEST 2013
tutti.config.help=config.html
tutti.createAccidentalBatch.action.cancel.help=editFishingOperation.html\#captureCapturesAccidentellesActions
tutti.createAccidentalBatch.action.saveAndClose.help=editFishingOperation.html\#captureCapturesAccidentellesActions
@@ -251,6 +251,7 @@
tutti.editSpeciesBatch.help=editFishingOperation.html\#captureEspeces
tutti.editSpeciesFrequencies.action.cancel.help=editFishingOperation.html\#captureEspecesMensurationActions
tutti.editSpeciesFrequencies.action.generate.help=editFishingOperation.html\#captureEspecesMensurationActions
+tutti.editSpeciesFrequencies.action.reset.help=
tutti.editSpeciesFrequencies.action.save.help=editFishingOperation.html\#captureEspecesMensurationActions
tutti.editSpeciesFrequencies.action.saveAndClose.help=
tutti.editSpeciesFrequencies.action.saveAndContinue.help=
Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-09-24 13:30:43 UTC (rev 1219)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-09-24 15:43:28 UTC (rev 1220)
@@ -1,5 +1,5 @@
#Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo
-#Sun Sep 22 16:40:00 CEST 2013
+#Tue Sep 24 16:21:02 CEST 2013
tutti.config.help=config.html
tutti.createAccidentalBatch.action.cancel.help=editFishingOperation.html\#captureCapturesAccidentellesActions
tutti.createAccidentalBatch.action.saveAndClose.help=editFishingOperation.html\#captureCapturesAccidentellesActions
@@ -249,6 +249,7 @@
tutti.editSpeciesBatch.help=editFishingOperation.html\#captureEspeces
tutti.editSpeciesFrequencies.action.cancel.help=editFishingOperation.html\#captureEspecesMensurationActions
tutti.editSpeciesFrequencies.action.generate.help=editFishingOperation.html\#captureEspecesMensurationActions
+tutti.editSpeciesFrequencies.action.reset.help=
tutti.editSpeciesFrequencies.action.saveAndClose.help=editFishingOperation.html\#captureEspecesMensurationActions
tutti.editSpeciesFrequencies.action.saveAndContinue.help=editFishingOperation.html\#captureEspecesMensurationActions
tutti.editSpeciesFrequencies.field.lengthStepCaracteristic.help=editFishingOperation.html\#captureEspecesMensurationFields
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-09-24 13:30:43 UTC (rev 1219)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-09-24 15:43:28 UTC (rev 1220)
@@ -676,7 +676,8 @@
// update speciesUsed
addToSpeciesUsed(newRow);
- if (batchRootRowModel.getSelectedCategory() != null) {
+ if (batchRootRowModel.getBatchCount() == null &&
+ batchRootRowModel.getSelectedCategory() != null) {
// add first category
splitBatch(batchRootRowModel.getSelectedCategory(),
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.css 2013-09-24 13:30:43 UTC (rev 1219)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.css 2013-09-24 15:43:28 UTC (rev 1220)
@@ -52,7 +52,7 @@
}
#categoryPanel {
- visible: {model.getSpecies() != null};
+ visible: {model.getSpecies() != null && model.getBatchCount() == null};
}
#sampleCategoryLabel {
@@ -79,7 +79,6 @@
property: batchWeight;
model: {model.getBatchWeight()};
useFloat: true;
- /*numberPattern: {DECIMAL3_PATTERN};*/
bean: {model};
}
@@ -112,6 +111,7 @@
showReset: false;
selectedItem: {model.getSelectedCategory()};
data: {model.getCategory()};
+ enabled: {model.getBatchCount() == null};
}
#sampleWeightLabel {
@@ -133,7 +133,7 @@
selectionBackground: {null};
selectionForeground: {Color.BLACK};
sortable: false;
- enabled: {model.getSelectedCategory() != null}
+ enabled: {model.getSelectedCategory() != null && model.getBatchCount() == null};
}
#addSpeciesButton {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.jaxx 2013-09-24 13:30:43 UTC (rev 1219)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.jaxx 2013-09-24 15:43:28 UTC (rev 1220)
@@ -67,8 +67,7 @@
<BeanValidator id='validator' bean='model'
uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
<field name='species' component='speciesComboBox'/>
- <field name='sampleCategory'
- component='sampleCategoryComboBox'/>
+ <field name='sampleCategory' component='sampleCategoryComboBox'/>
<field name='batchWeight' component='batchWeightField'/>
<field name='batchCount' component='batchCountField'/>
<field name='selectedCategory' component='categoryComboBox'/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.css 2013-09-24 13:30:43 UTC (rev 1219)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.css 2013-09-24 15:43:28 UTC (rev 1220)
@@ -295,3 +295,11 @@
enabled: {model.isValid()};
_help: {"tutti.editBenthosFrequencies.action.saveAndClose.help"};
}
+
+#resetButton {
+ actionIcon: reset;
+ text: "tutti.editSpeciesFrequencies.action.reset";
+ toolTipText: "tutti.editSpeciesFrequencies.action.reset.tip";
+ i18nMnemonic: "tutti.editSpeciesFrequencies.action.reset.mnemonic";
+ _help: {"tutti.editSpeciesFrequencies.action.reset.help"};
+}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.jaxx 2013-09-24 13:30:43 UTC (rev 1219)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.jaxx 2013-09-24 15:43:28 UTC (rev 1220)
@@ -205,9 +205,14 @@
</JPanel>
<JPanel id='dataFieldPanel' constraints='BorderLayout.CENTER'>
- <JScrollPane id='tableScrollPane' constraints='"lengthCaracteristicPmfm"'>
- <JXTable id='table'/>
- </JScrollPane>
+ <JPanel constraints='"lengthCaracteristicPmfm"'
+ layout='{new BorderLayout()}'>
+ <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
+ <JXTable id='table'/>
+ </JScrollPane>
+ <JButton id='resetButton' onActionPerformed='handler.reset()'
+ constraints='BorderLayout.SOUTH'/>
+ </JPanel>
<Table constraints='"noLengthCaracteristicPmfm"' fill='horizontal'>
<row>
<cell columns='2'>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java 2013-09-24 13:30:43 UTC (rev 1219)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java 2013-09-24 15:43:28 UTC (rev 1220)
@@ -130,6 +130,13 @@
}
@Override
+ protected void onModelRowsChanged(List<BenthosFrequencyRowModel> rows) {
+ super.onModelRowsChanged(rows);
+
+ recomputeTotalNumberAndWeight();
+ }
+
+ @Override
protected void onRowModified(int rowIndex,
BenthosFrequencyRowModel row,
String propertyName,
@@ -153,27 +160,14 @@
}
- List<BenthosFrequencyRowModel> rows = model.getRows();
- Integer totalNumber = 0;
- Float totalWeight = 0f;
- for (BenthosFrequencyRowModel r : rows) {
- if (recomputeAllRows) {
+ if (recomputeAllRows) {
+ for (BenthosFrequencyRowModel r : model.getRows()) {
recomputeRowValidState(r);
}
- if (r.isValid()) {
- Integer number = r.getNumber();
- if (number != null) {
- totalNumber += number;
- }
- Float weight = r.getWeight();
- if (weight != null) {
- totalWeight += weight;
- }
- }
}
- model.setTotalNumber(totalNumber);
- model.setTotalWeight(totalWeight);
+ recomputeTotalNumberAndWeight();
+
if (!recomputeAllRows) {
recomputeRowValidState(row);
}
@@ -615,6 +609,12 @@
model.setBatch(speciesBatch);
}
+ public void reset() {
+
+ // remove all frequencies
+ getModel().setRows(Lists.<BenthosFrequencyRowModel>newArrayList());
+ }
+
public void saveAndClose() {
if (log.isDebugEnabled()) {
@@ -699,4 +699,24 @@
//-- Internal methods --//
//------------------------------------------------------------------------//
+ protected void recomputeTotalNumberAndWeight() {
+ BenthosFrequencyUIModel model = getModel();
+ List<BenthosFrequencyRowModel> rows = model.getRows();
+ Integer totalNumber = 0;
+ Float totalWeight = 0f;
+ for (BenthosFrequencyRowModel r : rows) {
+ if (r.isValid()) {
+ Integer number = r.getNumber();
+ if (number != null) {
+ totalNumber += number;
+ }
+ Float weight = r.getWeight();
+ if (weight != null) {
+ totalWeight += weight;
+ }
+ }
+ }
+ model.setTotalNumber(totalNumber);
+ model.setTotalWeight(totalWeight);
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-09-24 13:30:43 UTC (rev 1219)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-09-24 15:43:28 UTC (rev 1220)
@@ -679,7 +679,8 @@
// update speciesUsed
addToSpeciesUsed(newRow);
- if (batchRootRowModel.getSelectedCategory() != null) {
+ if (batchRootRowModel.getBatchCount() == null &&
+ batchRootRowModel.getSelectedCategory() != null) {
// add first category
splitBatch(batchRootRowModel.getSelectedCategory(),
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.css 2013-09-24 13:30:43 UTC (rev 1219)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.css 2013-09-24 15:43:28 UTC (rev 1220)
@@ -79,7 +79,6 @@
property: batchWeight;
model: {model.getBatchWeight()};
useFloat: true;
- /*numberPattern: {DECIMAL3_PATTERN};*/
bean: {model};
}
@@ -112,6 +111,7 @@
showReset: false;
selectedItem: {model.getSelectedCategory()};
data: {model.getCategory()};
+ enabled: {model.getBatchCount() == null};
}
#sampleWeightLabel {
@@ -133,7 +133,7 @@
selectionBackground: {null};
selectionForeground: {Color.BLACK};
sortable: false;
- enabled: {model.getSelectedCategory() != null}
+ enabled: {model.getSelectedCategory() != null && model.getBatchCount() == null};
}
#addSpeciesButton {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.jaxx 2013-09-24 13:30:43 UTC (rev 1219)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.jaxx 2013-09-24 15:43:28 UTC (rev 1220)
@@ -67,8 +67,7 @@
<BeanValidator id='validator' bean='model'
uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
<field name='species' component='speciesComboBox'/>
- <field name='sampleCategory'
- component='sampleCategoryComboBox'/>
+ <field name='sampleCategory' component='sampleCategoryComboBox'/>
<field name='batchWeight' component='batchWeightField'/>
<field name='batchCount' component='batchCountField'/>
<field name='selectedCategory' component='categoryComboBox'/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css 2013-09-24 13:30:43 UTC (rev 1219)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css 2013-09-24 15:43:28 UTC (rev 1220)
@@ -296,3 +296,11 @@
_help: {"tutti.editSpeciesFrequencies.action.saveAndClose.help"};
}
+#resetButton {
+ actionIcon: reset;
+ text: "tutti.editSpeciesFrequencies.action.reset";
+ toolTipText: "tutti.editSpeciesFrequencies.action.reset.tip";
+ i18nMnemonic: "tutti.editSpeciesFrequencies.action.reset.mnemonic";
+ _help: {"tutti.editSpeciesFrequencies.action.reset.help"};
+}
+
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx 2013-09-24 13:30:43 UTC (rev 1219)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx 2013-09-24 15:43:28 UTC (rev 1220)
@@ -205,9 +205,15 @@
</JPanel>
<JPanel id='dataFieldPanel' constraints='BorderLayout.CENTER'>
- <JScrollPane id='tableScrollPane' constraints='"lengthCaracteristicPmfm"'>
- <JXTable id='table'/>
- </JScrollPane>
+ <JPanel constraints='"lengthCaracteristicPmfm"'
+ layout='{new BorderLayout()}'>
+ <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
+ <JXTable id='table'/>
+ </JScrollPane>
+ <JButton id='resetButton' onActionPerformed='handler.reset()'
+ constraints='BorderLayout.SOUTH'/>
+ </JPanel>
+
<Table constraints='"noLengthCaracteristicPmfm"' fill='horizontal'>
<row>
<cell columns='2'>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-09-24 13:30:43 UTC (rev 1219)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-09-24 15:43:28 UTC (rev 1220)
@@ -130,6 +130,13 @@
}
@Override
+ protected void onModelRowsChanged(List<SpeciesFrequencyRowModel> rows) {
+ super.onModelRowsChanged(rows);
+
+ recomputeTotalNumberAndWeight();
+ }
+
+ @Override
protected void onRowModified(int rowIndex,
SpeciesFrequencyRowModel row,
String propertyName,
@@ -152,27 +159,14 @@
recomputeAllRows = withWeightRows.isEmpty();
}
- List<SpeciesFrequencyRowModel> rows = model.getRows();
- Integer totalNumber = 0;
- Float totalWeight = 0f;
- for (SpeciesFrequencyRowModel r : rows) {
- if (recomputeAllRows) {
+ if (recomputeAllRows) {
+ for (SpeciesFrequencyRowModel r : model.getRows()) {
recomputeRowValidState(r);
}
- if (r.isValid()) {
- Integer number = r.getNumber();
- if (number != null) {
- totalNumber += number;
- }
- Float weight = r.getWeight();
- if (weight != null) {
- totalWeight += weight;
- }
- }
}
- model.setTotalNumber(totalNumber);
- model.setTotalWeight(totalWeight);
+ recomputeTotalNumberAndWeight();
+
if (!recomputeAllRows) {
recomputeRowValidState(row);
}
@@ -438,8 +432,8 @@
public void applyRafaleStep(Float step) {
- if (log.isInfoEnabled()) {
- log.info("Will apply rafale step: " + step);
+ if (log.isDebugEnabled()) {
+ log.debug("Will apply rafale step: " + step);
}
SpeciesFrequencyUIModel model = getModel();
SpeciesFrequencyTableModel tableModel = getTableModel();
@@ -614,6 +608,12 @@
model.setBatch(speciesBatch);
}
+ public void reset() {
+
+ // remove all frequencies
+ getModel().setRows(Lists.<SpeciesFrequencyRowModel>newArrayList());
+ }
+
public void saveAndClose() {
if (log.isDebugEnabled()) {
@@ -698,4 +698,24 @@
//-- Internal methods --//
//------------------------------------------------------------------------//
+ protected void recomputeTotalNumberAndWeight() {
+ SpeciesFrequencyUIModel model = getModel();
+ List<SpeciesFrequencyRowModel> rows = model.getRows();
+ Integer totalNumber = 0;
+ Float totalWeight = 0f;
+ for (SpeciesFrequencyRowModel r : rows) {
+ if (r.isValid()) {
+ Integer number = r.getNumber();
+ if (number != null) {
+ totalNumber += number;
+ }
+ Float weight = r.getWeight();
+ if (weight != null) {
+ totalWeight += weight;
+ }
+ }
+ }
+ model.setTotalNumber(totalNumber);
+ model.setTotalWeight(totalWeight);
+ }
}
Modified: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel-error-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel-error-validation.xml 2013-09-24 13:30:43 UTC (rev 1219)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel-error-validation.xml 2013-09-24 15:43:28 UTC (rev 1220)
@@ -69,28 +69,15 @@
</message>
</field-validator>
- </field>
-
- <field name="batchCount">
<field-validator type="fieldexpression" short-circuit="true">
<param name="expression">
- <![CDATA[ batchCount == null || !categoryIsFilled ]]>
+ <![CDATA[ batchCount != null || sampleWeight == null || batchWeight == null || sampleWeight <= batchWeight]]>
</param>
<message>
- tutti.validator.error.createSpeciesBatch.countAndCategories.notPossible
+ tutti.validator.error.splitSpeciesBatch.sampleWeight.sampleBatchGreaterThanBatchWeight
</message>
</field-validator>
- </field>
- <field name="selectedCategory">
- <field-validator type="fieldexpression" short-circuit="true">
- <param name="expression">
- <![CDATA[ batchCount == null || !categoryIsFilled ]]>
- </param>
- <message>
- tutti.validator.error.createSpeciesBatch.countAndCategories.notPossible
- </message>
- </field-validator>
</field>
<field name="sampleWeight">
@@ -105,7 +92,8 @@
<field-validator type="fieldexpression" short-circuit="true">
<param name="expression">
- <![CDATA[ sampleWeight == null || batchWeight == null || sampleWeight <= batchWeight]]></param>
+ <![CDATA[ batchCount != null || sampleWeight == null || batchWeight == null || sampleWeight <= batchWeight]]>
+ </param>
<message>
tutti.validator.error.splitSpeciesBatch.sampleWeight.sampleBatchGreaterThanBatchWeight
</message>
Modified: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel-error-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel-error-validation.xml 2013-09-24 13:30:43 UTC (rev 1219)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel-error-validation.xml 2013-09-24 15:43:28 UTC (rev 1220)
@@ -68,28 +68,15 @@
</message>
</field-validator>
- </field>
-
- <field name="batchCount">
<field-validator type="fieldexpression" short-circuit="true">
<param name="expression">
- <![CDATA[ batchCount == null || !categoryIsFilled ]]>
+ <![CDATA[ batchCount != null || sampleWeight == null || batchWeight == null || sampleWeight <= batchWeight]]>
</param>
<message>
- tutti.validator.error.createSpeciesBatch.countAndCategories.notPossible
+ tutti.validator.error.splitSpeciesBatch.sampleWeight.sampleBatchGreaterThanBatchWeight
</message>
</field-validator>
- </field>
- <field name="selectedCategory">
- <field-validator type="fieldexpression" short-circuit="true">
- <param name="expression">
- <![CDATA[ batchCount == null || !categoryIsFilled ]]>
- </param>
- <message>
- tutti.validator.error.createSpeciesBatch.countAndCategories.notPossible
- </message>
- </field-validator>
</field>
<field name="sampleWeight">
@@ -104,7 +91,8 @@
<field-validator type="fieldexpression" short-circuit="true">
<param name="expression">
- <![CDATA[ sampleWeight == null || batchWeight == null || sampleWeight <= batchWeight]]></param>
+ <![CDATA[ batchCount != null || sampleWeight == null || batchWeight == null || sampleWeight <= batchWeight]]>
+ </param>
<message>
tutti.validator.error.splitSpeciesBatch.sampleWeight.sampleBatchGreaterThanBatchWeight
</message>
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-09-24 13:30:43 UTC (rev 1219)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-09-24 15:43:28 UTC (rev 1220)
@@ -251,6 +251,7 @@
tutti.createSpeciesBatch.field.sampleWeight.tip=
tutti.createSpeciesBatch.field.species=
tutti.createSpeciesBatch.field.species.tip=
+tutti.createSpeciesBatch.message.countOrCategorize=
tutti.createSpeciesBatch.title=
tutti.createSpeciesMelag.action.cancel=
tutti.createSpeciesMelag.action.cancel.mnemonic=
@@ -948,6 +949,9 @@
tutti.editSpeciesFrequencies.action.generate=
tutti.editSpeciesFrequencies.action.generate.mnemonic=
tutti.editSpeciesFrequencies.action.generate.tip=
+tutti.editSpeciesFrequencies.action.reset=
+tutti.editSpeciesFrequencies.action.reset.mnemonic=
+tutti.editSpeciesFrequencies.action.reset.tip=
tutti.editSpeciesFrequencies.action.saveAndClose=
tutti.editSpeciesFrequencies.action.saveAndClose.mnemonic=
tutti.editSpeciesFrequencies.action.saveAndClose.tip=
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-09-24 13:30:43 UTC (rev 1219)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-09-24 15:43:28 UTC (rev 1220)
@@ -433,7 +433,7 @@
tutti.editBenthosFrequencies.action.saveAndClose.mnemonic=F
tutti.editBenthosFrequencies.action.saveAndClose.tip=Enregistrer les mensurations
tutti.editBenthosFrequencies.action.saveAndContinue=Enregistrer et Continuer
-tutti.editBenthosFrequencies.action.saveAndContinue.mnemonic=E
+tutti.editBenthosFrequencies.action.saveAndContinue.mnemonic=C
tutti.editBenthosFrequencies.action.saveAndContinue.tip=Enregistrer les mensurations et saisir les mensurations pour le lot suivant
tutti.editBenthosFrequencies.error.length.doublon=La classe de taille <strong>%s</strong> est utilisée plusieurs fois (deuxième occurrence trouvée à la ligne <strong>%s</strong>), ce qui n'est pas autorisé.<hr/>Veuillez corriger cela pour pouvoir enregistrer les mensurations.
tutti.editBenthosFrequencies.field.lengthStepCaracteristic=Type de mesure
@@ -948,11 +948,17 @@
tutti.editSpeciesFrequencies.action.generate=Générer
tutti.editSpeciesFrequencies.action.generate.mnemonic=G
tutti.editSpeciesFrequencies.action.generate.tip=Générer les mensurations
+tutti.editSpeciesFrequencies.action.reset=Réinitialiser
+tutti.editSpeciesFrequencies.action.reset.mnemonic=R
+tutti.editSpeciesFrequencies.action.reset.tip=Supprimer toutes les mensurations saisies
+tutti.editBenthosFrequencies.action.reset=Réinitialiser
+tutti.editbenthosFrequencies.action.reset.mnemonic=R
+tutti.editBenthosFrequencies.action.reset.tip=Supprimer toutes les mensurations saisies
tutti.editSpeciesFrequencies.action.saveAndClose=Enregistrer et Fermer
tutti.editSpeciesFrequencies.action.saveAndClose.mnemonic=F
tutti.editSpeciesFrequencies.action.saveAndClose.tip=Enregistrer les mensurations
tutti.editSpeciesFrequencies.action.saveAndContinue=Enregistrer et Continuer
-tutti.editSpeciesFrequencies.action.saveAndContinue.mnemonic=E
+tutti.editSpeciesFrequencies.action.saveAndContinue.mnemonic=C
tutti.editSpeciesFrequencies.action.saveAndContinue.tip=Enregistrer les mensurations et saisir les mensurations pour le lot suivant
tutti.editSpeciesFrequencies.error.length.doublon=La classe de taille <strong>%s</strong> est utilisée plusieurs fois (deuxième occurrence trouvée à la ligne <strong>%s</strong>), ce qui n'est pas autorisé.<hr/>Veuillez corriger cela pour pouvoir enregistrer les mensurations.
tutti.editSpeciesFrequencies.field.lengthStepCaracteristic=Type de mesure
1
0
24 Sep '13
Author: tchemit
Date: 2013-09-24 15:30:43 +0200 (Tue, 24 Sep 2013)
New Revision: 1219
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1219
Log:
fixes #3312: [CAPTURES] - Ajouter une d?\195?\169cimale aux poids (4 d?\195?\169cimales pour les poids en kg et une d?\195?\169cimale pour les grammes)
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/create/CreateAccidentalBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/CreateIndividualObservationBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUI.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/WeightUnit.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-09-24 13:30:43 UTC (rev 1219)
@@ -28,7 +28,7 @@
bean: {model};
showReset: true;
useFloat: true;
- numberPattern: {DECIMAL3_PATTERN};
+ /*numberPattern: {DECIMAL3_PATTERN};*/
_selectOnFocus: {true};
}
@@ -37,8 +37,8 @@
showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
showReset: true;
useFloat: true;
- numberPattern: {DECIMAL3_PATTERN};
- decimalNumber: 3;
+ /*numberPattern: {DECIMAL3_PATTERN};
+ decimalNumber: 3;*/
computedDataColor: {handler.getConfig().getColorComputedWeights()};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryComponent.java 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryComponent.java 2013-09-24 13:30:43 UTC (rev 1219)
@@ -26,6 +26,7 @@
import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.WeightUnit;
import jaxx.runtime.JAXXUtil;
import jaxx.runtime.swing.editor.NumberEditor;
import org.nuiton.decorator.Decorator;
@@ -63,8 +64,9 @@
return new SampleCategoryRenderer<C>(renderer, decorator, computedDataColor);
}
- public static <C extends Serializable> TableCellEditor newEditor(Decorator<C> decorator) {
- return new SampleCategoryEditor<C>(decorator);
+ public static <C extends Serializable> TableCellEditor newEditor(Decorator<C> decorator,
+ WeightUnit weightUnit) {
+ return new SampleCategoryEditor<C>(decorator, weightUnit);
}
/**
@@ -86,7 +88,7 @@
protected final Decorator<C> categoryDecorator;
- public SampleCategoryEditor(Decorator<C> categoryDecorator) {
+ public SampleCategoryEditor(Decorator<C> categoryDecorator, WeightUnit weightUnit) {
this.categoryDecorator = categoryDecorator;
numberEditor = new NumberEditor();
numberEditor.getTextField().setHorizontalAlignment(SwingConstants.RIGHT);
@@ -95,6 +97,7 @@
numberEditor.getTextField().addAncestorListener(this);
numberEditor.setModelType(Float.class);
numberEditor.setUseSign(false);
+ numberEditor.setNumberPattern(weightUnit.getNumberEditorPattern());
numberEditor.init();
editor = new JPanel(new BorderLayout());
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.css 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.css 2013-09-24 13:30:43 UTC (rev 1219)
@@ -39,6 +39,17 @@
borderPainted: false;
}
+#tablePopup {
+ label: "tutti.editAccidentalBatch.title.batchActions";
+}
+
+#table {
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ selectionBackground: {null};
+ selectionForeground: {Color.BLACK};
+ sortable: false;
+}
+
#importMultiPostButton {
actionIcon: import;
text: "tutti.editAccidentalBatch.action.importMultiPost";
@@ -57,17 +68,6 @@
_help: {"tutti.editAccidentalBatch.action.exportMultiPost.help"};
}
-#tablePopup {
- label: "tutti.editAccidentalBatch.title.batchActions";
-}
-
-#table {
- selectionMode: {ListSelectionModel.SINGLE_SELECTION};
- selectionBackground: {null};
- selectionForeground: {Color.BLACK};
- sortable: false;
-}
-
#createAccidentalBatchButton {
actionIcon: batch-create;
text: "tutti.editAccidentalBatch.action.createBatch";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2013-09-24 13:30:43 UTC (rev 1219)
@@ -262,7 +262,6 @@
table.addHighlighter(commentHighlighter);
// paint in a special color for attachment cell (when some attachments)
-
Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
new HighlightPredicate.AndHighlightPredicate(
new HighlightPredicate.IdentifierHighlightPredicate(AccidentalBatchTableModel.ATTACHMENT),
@@ -344,7 +343,6 @@
addFloatColumnToModel(columnModel,
AccidentalBatchTableModel.WEIGHT,
- TuttiUI.DECIMAL3_PATTERN,
weightUnit);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/create/CreateAccidentalBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/create/CreateAccidentalBatchUI.css 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/create/CreateAccidentalBatchUI.css 2013-09-24 13:30:43 UTC (rev 1219)
@@ -70,7 +70,6 @@
#accidentalWeightField {
property: weight;
useFloat: true;
- numberPattern: {DECIMAL3_PATTERN};
bean: {model};
model: {model.getWeight()};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 2013-09-24 13:30:43 UTC (rev 1219)
@@ -28,7 +28,7 @@
bean: {model};
showReset: true;
useFloat: true;
- numberPattern: {DECIMAL3_PATTERN};
+ /*numberPattern: {DECIMAL3_PATTERN};*/
_selectOnFocus: {true};
}
@@ -37,8 +37,8 @@
showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
showReset: true;
useFloat: true;
- numberPattern: {DECIMAL3_PATTERN};
- decimalNumber: 3;
+ /*numberPattern: {DECIMAL3_PATTERN};
+ decimalNumber: 3;*/
computedDataColor: {handler.getConfig().getColorComputedWeights()};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-09-24 13:30:43 UTC (rev 1219)
@@ -117,6 +117,11 @@
protected ValidationService validationService = getContext().getValidationService();
+ /**
+ * Sample categories model.
+ *
+ * @since 2.4
+ */
protected final SampleCategoryModel sampleCategoryModel;
/**
@@ -266,7 +271,7 @@
List<BenthosBatchFrequency> frequencies =
BenthosFrequencyRowModel.toEntity(
row.getFrequency(),
- batch);
+ batch);
result = TuttiProtocols.isBenthosBatchValid(
getDataContext().getProtocol(),
batch,
@@ -453,7 +458,6 @@
table.addHighlighter(commentHighlighter);
// paint in a special color for attachment cell (when some attachments)
-
Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
new HighlightPredicate.AndHighlightPredicate(
new HighlightPredicate.IdentifierHighlightPredicate(BenthosBatchTableModel.ATTACHMENT),
@@ -554,9 +558,9 @@
addColumnToModel(columnModel,
TuttiComputedOrNotDataTableCell.newEditor(
- Float.class, false, true, 3, computedDataColor),
+ Float.class, weightUnit, computedDataColor),
TuttiComputedOrNotDataTableCell.newRender(
- defaultRenderer, true, 3, computedDataColor),
+ defaultRenderer, weightUnit, computedDataColor),
BenthosBatchTableModel.WEIGHT,
weightUnit);
}
@@ -891,7 +895,7 @@
List<BenthosBatchFrequency> frequency =
BenthosFrequencyRowModel.toEntity(
frequencyRows,
- entityToSave);
+ entityToSave);
if (log.isInfoEnabled()) {
log.info("Will save " + frequency.size() + " frequencies.");
@@ -1151,7 +1155,7 @@
WeightUnit weightUnit) {
addColumnToModel(
columnModel,
- SampleCategoryComponent.newEditor(decorator),
+ SampleCategoryComponent.newEditor(decorator, weightUnit),
SampleCategoryComponent.newRender(defaultRenderer,
decorator,
getConfig().getColorComputedWeights()),
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.css 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.css 2013-09-24 13:30:43 UTC (rev 1219)
@@ -79,7 +79,7 @@
property: batchWeight;
model: {model.getBatchWeight()};
useFloat: true;
- numberPattern: {DECIMAL3_PATTERN};
+ /*numberPattern: {DECIMAL3_PATTERN};*/
bean: {model};
}
@@ -93,7 +93,7 @@
#batchCountField {
property: batchCount;
model: {model.getBatchCount()};
- useFloat: true;
+ useFloat: false;
numberPattern: {INT_6_DIGITS_PATTERN};
bean: {model};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java 2013-09-24 13:30:43 UTC (rev 1219)
@@ -46,6 +46,7 @@
import fr.ifremer.tutti.ui.swing.util.Cancelable;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
+import fr.ifremer.tutti.ui.swing.util.WeightUnit;
import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUI;
import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUIModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
@@ -76,10 +77,27 @@
private final TuttiPersistence persistenceService;
- private final CaracteristicQualitativeValue sortedValue;
+ /**
+ * Qualitative value for the Vrac.
+ *
+ * @since 2.5
+ */
+ protected final CaracteristicQualitativeValue sortedValue;
- private SampleCategoryModel sampleCategoryModel;
+ /**
+ * Sample categories model.
+ *
+ * @since 2.4
+ */
+ protected final SampleCategoryModel sampleCategoryModel;
+ /**
+ * Weight unit.
+ *
+ * @since 2.6
+ */
+ protected final WeightUnit weightUnit;
+
public CreateBenthosBatchUIHandler(TuttiUI parentUi,
CreateBenthosBatchUI ui) {
super(parentUi.getHandler().getContext(), ui,
@@ -87,7 +105,7 @@
SplitBenthosBatchRowModel.PROPERTY_CATEGORY_VALUE,
SplitBenthosBatchRowModel.PROPERTY_WEIGHT);
this.persistenceService = context.getPersistenceService();
-
+ this.weightUnit = getConfig().getBenthosWeightUnit();
this.sampleCategoryModel = getDataContext().getSampleCategoryModel();
SampleCategoryModelEntry caracteristic = sampleCategoryModel.getCategoryById(sampleCategoryModel.getFirstCategoryId());
@@ -515,8 +533,7 @@
addFloatColumnToModel(columnModel,
SplitBenthosBatchTableModel.WEIGHT,
- TuttiUI.DECIMAL3_PATTERN,
- getConfig().getBenthosWeightUnit());
+ weightUnit);
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.css 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.css 2013-09-24 13:30:43 UTC (rev 1219)
@@ -177,33 +177,6 @@
enabled: false;
}
-#autoGenModeButton {
- text: "tutti.editBenthosFrequencies.field.mode.autoGen";
- toolTipText: "tutti.editBenthosFrequencies.field.mode.autoGen.tip";
- value: "autoGenMode";
- selected: {model.isAutoGenMode()};
- buttonGroup: "mode";
- _help: {"tutti.editBenthosFrequencies.field.mode.autoGen.help"};
-}
-
-#rafaleModeButton {
- text: "tutti.editBenthosFrequencies.field.mode.rafale";
- toolTipText: "tutti.editBenthosFrequencies.field.mode.rafale.tip";
- value: "rafaleMode";
- selected: {model.isRafaleMode()};
- buttonGroup: "mode";
- _help: {"tutti.editBenthosFrequencies.field.mode.rafale.help"};
-}
-
-#simpleCountingModeButton {
- text: "tutti.editBenthosFrequencies.field.mode.simpleCounting";
- toolTipText: "tutti.editBenthosFrequencies.field.mode.simpleCounting.tip";
- value: "simpleCountingMode";
- selected: {model.isSimpleCountingMode()};
- buttonGroup: "mode";
- _help: {"tutti.editBenthosFrequencies.field.mode.simpleCounting.help"};
-}
-
#simpleCountingModeLabel {
text: "tutti.editBenthosFrequencies.label.no.configuration";
horizontalAlignment: {JLabel.CENTER};
@@ -250,6 +223,44 @@
bean: {model};
}
+#dataInFrequenciesWarningContainer {
+ background: {new java.awt.Color(245, 218, 88)};
+ visible: {(model.getRowsInError().size() + model.getEmptyRows().size()) != model.getRows().size()};
+}
+
+#dataInFrequenciesWarning {
+ actionIcon: warning;
+ border: {new javax.swing.border.EmptyBorder(5, 10, 5, 10)};
+ text: "tutti.editBenthosFrequencies.simpleCountingAndFrequencies";
+}
+
+#autoGenModeButton {
+ text: "tutti.editBenthosFrequencies.field.mode.autoGen";
+ toolTipText: "tutti.editBenthosFrequencies.field.mode.autoGen.tip";
+ value: "autoGenMode";
+ selected: {model.isAutoGenMode()};
+ buttonGroup: "mode";
+ _help: {"tutti.editBenthosFrequencies.field.mode.autoGen.help"};
+}
+
+#rafaleModeButton {
+ text: "tutti.editBenthosFrequencies.field.mode.rafale";
+ toolTipText: "tutti.editBenthosFrequencies.field.mode.rafale.tip";
+ value: "rafaleMode";
+ selected: {model.isRafaleMode()};
+ buttonGroup: "mode";
+ _help: {"tutti.editBenthosFrequencies.field.mode.rafale.help"};
+}
+
+#simpleCountingModeButton {
+ text: "tutti.editBenthosFrequencies.field.mode.simpleCounting";
+ toolTipText: "tutti.editBenthosFrequencies.field.mode.simpleCounting.tip";
+ value: "simpleCountingMode";
+ selected: {model.isSimpleCountingMode()};
+ buttonGroup: "mode";
+ _help: {"tutti.editBenthosFrequencies.field.mode.simpleCounting.help"};
+}
+
#generateButton {
actionIcon: generate;
text: "tutti.editBenthosFrequencies.action.generate";
@@ -284,14 +295,3 @@
enabled: {model.isValid()};
_help: {"tutti.editBenthosFrequencies.action.saveAndClose.help"};
}
-
-#dataInFrequenciesWarningContainer {
- background: {new java.awt.Color(245, 218, 88)};
- visible: {(model.getRowsInError().size() + model.getEmptyRows().size()) != model.getRows().size()};
-}
-
-#dataInFrequenciesWarning {
- actionIcon: warning;
- border: {new javax.swing.border.EmptyBorder(5, 10, 5, 10)};
- text: "tutti.editBenthosFrequencies.simpleCountingAndFrequencies";
-}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java 2013-09-24 13:30:43 UTC (rev 1219)
@@ -324,7 +324,6 @@
addFloatColumnToModel(columnModel,
BenthosFrequencyTableModel.WEIGHT,
- TuttiUI.DECIMAL3_PATTERN,
weightUnit);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIHandler.java 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIHandler.java 2013-09-24 13:30:43 UTC (rev 1219)
@@ -390,7 +390,6 @@
addFloatColumnToModel(columnModel,
SplitBenthosBatchTableModel.WEIGHT,
- TuttiUI.DECIMAL3_PATTERN,
getConfig().getBenthosWeightUnit());
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java 2013-09-24 13:30:43 UTC (rev 1219)
@@ -360,7 +360,6 @@
addFloatColumnToModel(columnModel,
IndividualObservationBatchTableModel.WEIGHT,
- TuttiUI.DECIMAL3_PATTERN,
weightUnit);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/CreateIndividualObservationBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/CreateIndividualObservationBatchUI.css 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/CreateIndividualObservationBatchUI.css 2013-09-24 13:30:43 UTC (rev 1219)
@@ -28,6 +28,8 @@
NumberEditor {
autoPopup: {handler.getConfig().isAutoPopupNumberEditor()};
showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
+ bean: {model};
+ useFloat: true;
showReset: true;
}
@@ -57,10 +59,8 @@
#individualObservationWeightField {
property: weight;
- useFloat: true;
- numberPattern: {DECIMAL3_PATTERN};
- bean: {model};
model: {model.getWeight()};
+ /*numberPattern: {DECIMAL3_PATTERN};*/
}
#individualObservationSizeLabel {
@@ -72,10 +72,8 @@
#individualObservationSizeField {
property: size;
- useFloat: true;
- numberPattern: {DECIMAL3_PATTERN};
- bean: {model};
model: {model.getSize()};
+ /*numberPattern: {DECIMAL3_PATTERN};*/
}
#individualObservationLengthStepCaracteristicLabel {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css 2013-09-24 13:30:43 UTC (rev 1219)
@@ -27,8 +27,8 @@
showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
showReset: true;
useFloat: true;
- numberPattern: {DECIMAL3_PATTERN};
- decimalNumber: 3;
+ /*numberPattern: {DECIMAL3_PATTERN};
+ decimalNumber: 3;*/
computedDataColor: {handler.getConfig().getColorComputedWeights()};
}
@@ -42,24 +42,6 @@
borderPainted: false;
}
-#importMultiPostButton {
- actionIcon: import;
- text: "tutti.editMarineLitterBatch.action.importMultiPost";
- toolTipText: "tutti.editMarineLitterBatch.action.importMultiPost.tip";
- i18nMnemonic: "tutti.editMarineLitterBatch.action.importMultiPost.mnemonic";
- _tuttiAction: {ImportMultiPostAction.class};
- _help: {"tutti.editMarineLitterBatch.action.importMultiPost.help"};
-}
-
-#exportMultiPostButton {
- actionIcon: export;
- text: "tutti.editMarineLitterBatch.action.exportMultiPost";
- toolTipText: "tutti.editMarineLitterBatch.action.exportMultiPost.tip";
- i18nMnemonic: "tutti.editMarineLitterBatch.action.exportMultiPost.mnemonic";
- _tuttiAction: {ExportMultiPostAction.class};
- _help: {"tutti.editMarineLitterBatch.action.exportMultiPost.help"};
-}
-
#marineLitterTotalWeightLabel {
text: "tutti.editMarineLitterBatch.field.marineLitterTotalWeight";
toolTipText: "tutti.editMarineLitterBatch.field.marineLitterTotalWeight.tip";
@@ -84,6 +66,24 @@
sortable: false;
}
+#importMultiPostButton {
+ actionIcon: import;
+ text: "tutti.editMarineLitterBatch.action.importMultiPost";
+ toolTipText: "tutti.editMarineLitterBatch.action.importMultiPost.tip";
+ i18nMnemonic: "tutti.editMarineLitterBatch.action.importMultiPost.mnemonic";
+ _tuttiAction: {ImportMultiPostAction.class};
+ _help: {"tutti.editMarineLitterBatch.action.importMultiPost.help"};
+}
+
+#exportMultiPostButton {
+ actionIcon: export;
+ text: "tutti.editMarineLitterBatch.action.exportMultiPost";
+ toolTipText: "tutti.editMarineLitterBatch.action.exportMultiPost.tip";
+ i18nMnemonic: "tutti.editMarineLitterBatch.action.exportMultiPost.mnemonic";
+ _tuttiAction: {ExportMultiPostAction.class};
+ _help: {"tutti.editMarineLitterBatch.action.exportMultiPost.help"};
+}
+
#createMarineLitterBatchButton {
actionIcon: batch-create;
text: "tutti.editMarineLitterBatch.action.createBatch";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java 2013-09-24 13:30:43 UTC (rev 1219)
@@ -348,7 +348,6 @@
addFloatColumnToModel(columnModel,
MarineLitterBatchTableModel.WEIGHT,
- TuttiUI.DECIMAL3_PATTERN,
weightUnit);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUI.css 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUI.css 2013-09-24 13:30:43 UTC (rev 1219)
@@ -30,8 +30,9 @@
NumberEditor {
autoPopup: {handler.getConfig().isAutoPopupNumberEditor()};
showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
- showReset: true;
bean: {model};
+ showReset: true;
+ useFloat: true;
}
#createMarineLitterBatchTopPanel {
@@ -72,7 +73,6 @@
#marineLitterNumberField {
property: number;
model: {model.getNumber()};
- useFloat: true;
numberPattern: {DECIMAL3_PATTERN};
}
@@ -87,8 +87,7 @@
#marineLitterWeightField {
property: weight;
model: {model.getWeight()};
- useFloat: true;
- numberPattern: {DECIMAL3_PATTERN};
+ /*numberPattern: {DECIMAL3_PATTERN};*/
}
#saveAndContinueButton {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-09-24 13:30:43 UTC (rev 1219)
@@ -28,7 +28,7 @@
bean: {model};
showReset: true;
useFloat: true;
- numberPattern: {DECIMAL3_PATTERN};
+ /*numberPattern: {DECIMAL3_PATTERN};*/
_selectOnFocus: {true};
}
@@ -37,8 +37,8 @@
showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
showReset: true;
useFloat: true;
- numberPattern: {DECIMAL3_PATTERN};
- decimalNumber: 3;
+ /*numberPattern: {DECIMAL3_PATTERN};
+ decimalNumber: 3;*/
computedDataColor: {handler.getConfig().getColorComputedWeights()};
}
@@ -52,33 +52,6 @@
borderPainted: false;
}
-#importPupitriButton {
- actionIcon: pupitri-import;
- text: "tutti.editSpeciesBatch.action.importPupitri";
- toolTipText: "tutti.editSpeciesBatch.action.importPupitri.tip";
- i18nMnemonic: "tutti.editSpeciesBatch.action.importPupitri.mnemonic";
- _tuttiAction: {ImportPupitriAction.class};
- _help: {"tutti.editSpeciesBatch.action.importPupitri.help"};
-}
-
-#importMultiPostButton {
- actionIcon: import;
- text: "tutti.editSpeciesBatch.action.importMultiPost";
- toolTipText: "tutti.editSpeciesBatch.action.importMultiPost.tip";
- i18nMnemonic: "tutti.editSpeciesBatch.action.importMultiPost.mnemonic";
- _tuttiAction: {ImportMultiPostAction.class};
- _help: {"tutti.editSpeciesBatch.action.importMultiPost.help"};
-}
-
-#exportMultiPostButton {
- actionIcon: export;
- text: "tutti.editSpeciesBatch.action.exportMultiPost";
- toolTipText: "tutti.editSpeciesBatch.action.exportMultiPost.tip";
- i18nMnemonic: "tutti.editSpeciesBatch.action.exportMultiPost.mnemonic";
- _tuttiAction: {ExportMultiPostAction.class};
- _help: {"tutti.editSpeciesBatch.action.exportMultiPost.help"};
-}
-
#speciesTotalWeightLabel {
text: "tutti.editSpeciesBatch.field.speciesTotalWeight";
toolTipText: "tutti.editSpeciesBatch.field.speciesTotalWeight.tip";
@@ -180,30 +153,6 @@
_help: {"tutti.editSpeciesBatch.filterSpeciesBatch.help"};
}
-#filterSpeciesBatchAllButton {
- text: "tutti.editSpeciesBatch.filterBatch.mode.all";
- toolTipText: "tutti.editSpeciesBatch.filterBatch.mode.all.tip";
- value: "all";
- selected: {model.isTableViewModeAll()};
- buttonGroup: "filterSpeciesBatchMode";
-}
-
-#filterSpeciesBatchLeafButton {
- text: "tutti.editSpeciesBatch.filterBatch.mode.leaf";
- toolTipText: "tutti.editSpeciesBatch.filterBatch.mode.leaf.tip";
- value: "leaf";
- selected: {model.isTableViewModeLeaf()};
- buttonGroup: "filterSpeciesBatchMode";
-}
-
-#filterSpeciesBatchRootButton {
- text: {handler.getFilterSpeciesBatchRootButtonText(model.getRootNumber())};
- toolTipText: "tutti.editSpeciesBatch.filterBatch.mode.root.tip";
- value: "root";
- selected: {model.isTableViewModeRoot()};
- buttonGroup: "filterSpeciesBatchMode";
-}
-
#splitSpeciesBatchMenu {
actionIcon: batch-split;
text: "tutti.editSpeciesBatch.action.splitBatch";
@@ -253,6 +202,66 @@
_help: {"tutti.editSpeciesBatch.action.createMelag.help"};
}
+#editFrequenciesMenu {
+ actionIcon: show-frequency;
+ text: "tutti.editSpeciesBatch.action.editFrequencies";
+ toolTipText: "tutti.editSpeciesBatch.action.editFrequencies.tip";
+ i18nMnemonic: "tutti.editSpeciesBatch.action.editFrequencies.mnemonic";
+ enabled: {model.isTableViewModeAll() && model.isEditFrequenciesEnabled()};
+ _help: {"tutti.editSpeciesBatch.action.editFrequencies.help"};
+}
+
+#importPupitriButton {
+ actionIcon: pupitri-import;
+ text: "tutti.editSpeciesBatch.action.importPupitri";
+ toolTipText: "tutti.editSpeciesBatch.action.importPupitri.tip";
+ i18nMnemonic: "tutti.editSpeciesBatch.action.importPupitri.mnemonic";
+ _tuttiAction: {ImportPupitriAction.class};
+ _help: {"tutti.editSpeciesBatch.action.importPupitri.help"};
+}
+
+#importMultiPostButton {
+ actionIcon: import;
+ text: "tutti.editSpeciesBatch.action.importMultiPost";
+ toolTipText: "tutti.editSpeciesBatch.action.importMultiPost.tip";
+ i18nMnemonic: "tutti.editSpeciesBatch.action.importMultiPost.mnemonic";
+ _tuttiAction: {ImportMultiPostAction.class};
+ _help: {"tutti.editSpeciesBatch.action.importMultiPost.help"};
+}
+
+#exportMultiPostButton {
+ actionIcon: export;
+ text: "tutti.editSpeciesBatch.action.exportMultiPost";
+ toolTipText: "tutti.editSpeciesBatch.action.exportMultiPost.tip";
+ i18nMnemonic: "tutti.editSpeciesBatch.action.exportMultiPost.mnemonic";
+ _tuttiAction: {ExportMultiPostAction.class};
+ _help: {"tutti.editSpeciesBatch.action.exportMultiPost.help"};
+}
+
+#filterSpeciesBatchAllButton {
+ text: "tutti.editSpeciesBatch.filterBatch.mode.all";
+ toolTipText: "tutti.editSpeciesBatch.filterBatch.mode.all.tip";
+ value: "all";
+ selected: {model.isTableViewModeAll()};
+ buttonGroup: "filterSpeciesBatchMode";
+}
+
+#filterSpeciesBatchLeafButton {
+ text: "tutti.editSpeciesBatch.filterBatch.mode.leaf";
+ toolTipText: "tutti.editSpeciesBatch.filterBatch.mode.leaf.tip";
+ value: "leaf";
+ selected: {model.isTableViewModeLeaf()};
+ buttonGroup: "filterSpeciesBatchMode";
+}
+
+#filterSpeciesBatchRootButton {
+ text: {handler.getFilterSpeciesBatchRootButtonText(model.getRootNumber())};
+ toolTipText: "tutti.editSpeciesBatch.filterBatch.mode.root.tip";
+ value: "root";
+ selected: {model.isTableViewModeRoot()};
+ buttonGroup: "filterSpeciesBatchMode";
+}
+
#createSpeciesBatchButton {
actionIcon: batch-create;
text: "tutti.editSpeciesBatch.action.createBatch";
@@ -261,12 +270,3 @@
enabled: {model.isCreateBatchEnabled()};
_help: {"tutti.editSpeciesBatch.action.createBatch.help"};
}
-
-#editFrequenciesMenu {
- actionIcon: show-frequency;
- text: "tutti.editSpeciesBatch.action.editFrequencies";
- toolTipText: "tutti.editSpeciesBatch.action.editFrequencies.tip";
- i18nMnemonic: "tutti.editSpeciesBatch.action.editFrequencies.mnemonic";
- enabled: {model.isTableViewModeAll() && model.isEditFrequenciesEnabled()};
- _help: {"tutti.editSpeciesBatch.action.editFrequencies.help"};
-}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-09-24 13:30:43 UTC (rev 1219)
@@ -117,6 +117,11 @@
protected final EditCatchesUI parentUi;
+ /**
+ * Sample categories model.
+ *
+ * @since 2.4
+ */
protected final SampleCategoryModel sampleCategoryModel;
/**
@@ -273,7 +278,7 @@
List<SpeciesBatchFrequency> frequencies =
SpeciesFrequencyRowModel.toEntity(
row.getFrequency(),
- batch);
+ batch);
result = TuttiProtocols.isSpeciesBatchValid(getDataContext().getProtocol(),
batch,
frequencies);
@@ -555,9 +560,9 @@
addColumnToModel(columnModel,
TuttiComputedOrNotDataTableCell.newEditor(
- Float.class, false, true, 3, computedDataColor),
+ Float.class, weightUnit, computedDataColor),
TuttiComputedOrNotDataTableCell.newRender(
- defaultRenderer, true, 3, computedDataColor),
+ defaultRenderer, weightUnit, computedDataColor),
SpeciesBatchTableModel.WEIGHT,
weightUnit);
}
@@ -891,7 +896,7 @@
List<SpeciesBatchFrequency> frequency =
SpeciesFrequencyRowModel.toEntity(
frequencyRows,
- catchBean);
+ catchBean);
if (log.isInfoEnabled()) {
log.info("Will save " + frequency.size() + " frequencies.");
@@ -1152,10 +1157,11 @@
WeightUnit weightUnit) {
addColumnToModel(
columnModel,
- SampleCategoryComponent.newEditor(decorator),
+ SampleCategoryComponent.newEditor(decorator, weightUnit),
SampleCategoryComponent.newRender(defaultRenderer,
decorator,
- getConfig().getColorComputedWeights()),
+ getConfig().getColorComputedWeights()
+ ),
columnIdentifier,
weightUnit);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.css 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.css 2013-09-24 13:30:43 UTC (rev 1219)
@@ -79,7 +79,7 @@
property: batchWeight;
model: {model.getBatchWeight()};
useFloat: true;
- numberPattern: {DECIMAL3_PATTERN};
+ /*numberPattern: {DECIMAL3_PATTERN};*/
bean: {model};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java 2013-09-24 13:30:43 UTC (rev 1219)
@@ -46,6 +46,7 @@
import fr.ifremer.tutti.ui.swing.util.Cancelable;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
+import fr.ifremer.tutti.ui.swing.util.WeightUnit;
import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUI;
import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUIModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
@@ -77,10 +78,27 @@
private final TuttiPersistence persistenceService;
- private final CaracteristicQualitativeValue sortedValue;
+ /**
+ * Qualitative value for the Vrac.
+ *
+ * @since 2.5
+ */
+ protected final CaracteristicQualitativeValue sortedValue;
- private SampleCategoryModel sampleCategoryModel;
+ /**
+ * Sample categories model.
+ *
+ * @since 2.4
+ */
+ protected final SampleCategoryModel sampleCategoryModel;
+ /**
+ * Weight unit.
+ *
+ * @since 2.6
+ */
+ protected final WeightUnit weightUnit;
+
public CreateSpeciesBatchUIHandler(TuttiUI parentUi,
CreateSpeciesBatchUI ui) {
super(parentUi.getHandler().getContext(), ui,
@@ -88,7 +106,7 @@
SplitSpeciesBatchRowModel.PROPERTY_CATEGORY_VALUE,
SplitSpeciesBatchRowModel.PROPERTY_WEIGHT);
this.persistenceService = context.getPersistenceService();
-
+ this.weightUnit = getConfig().getSpeciesWeightUnit();
this.sampleCategoryModel = getDataContext().getSampleCategoryModel();
SampleCategoryModelEntry caracteristic = sampleCategoryModel.getCategoryById(sampleCategoryModel.getFirstCategoryId());
@@ -498,8 +516,7 @@
editableCategoryValue = true;
addFloatColumnToModel(columnModel,
SplitSpeciesBatchTableModel.EDITABLE_CATEGORY_VALUE,
- TuttiUI.DECIMAL1_PATTERN,
- getConfig().getSpeciesWeightUnit());
+ TuttiUI.DECIMAL1_PATTERN);
}
if (data != null) {
@@ -516,7 +533,7 @@
addFloatColumnToModel(columnModel,
SplitSpeciesBatchTableModel.WEIGHT,
- TuttiUI.DECIMAL3_PATTERN);
+ weightUnit);
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css 2013-09-24 13:30:43 UTC (rev 1219)
@@ -162,48 +162,12 @@
layout: {modeConfigurationLayout};
}
-#simpleModeButton {
- text: "tutti.editSpeciesFrequencies.field.mode.simple";
- toolTipText: "tutti.editSpeciesFrequencies.field.mode.simple.tip";
- value: "simpleMode";
- selected: {model.isSimpleMode()};
- buttonGroup: "mode";
- _help: {"tutti.editSpeciesFrequencies.field.mode.simple.help"};
-}
-
#simpleModeLabel {
text: "tutti.editSpeciesFrequencies.label.no.configuration";
horizontalAlignment: {JLabel.CENTER};
enabled: false;
}
-#autoGenModeButton {
- text: "tutti.editSpeciesFrequencies.field.mode.autoGen";
- toolTipText: "tutti.editSpeciesFrequencies.field.mode.autoGen.tip";
- value: "autoGenMode";
- selected: {model.isAutoGenMode()};
- buttonGroup: "mode";
- _help: {"tutti.editSpeciesFrequencies.field.mode.autoGen.help"};
-}
-
-#rafaleModeButton {
- text: "tutti.editSpeciesFrequencies.field.mode.rafale";
- toolTipText: "tutti.editSpeciesFrequencies.field.mode.rafale.tip";
- value: "rafaleMode";
- selected: {model.isRafaleMode()};
- buttonGroup: "mode";
- _help: {"tutti.editSpeciesFrequencies.field.mode.rafale.help"};
-}
-
-#simpleCountingModeButton {
- text: "tutti.editSpeciesFrequencies.field.mode.simpleCounting";
- toolTipText: "tutti.editSpeciesFrequencies.field.mode.simpleCounting.tip";
- value: "simpleCountingMode";
- selected: {model.isSimpleCountingMode()};
- buttonGroup: "mode";
- _help: {"tutti.editSpeciesFrequencies.field.mode.simpleCounting.help"};
-}
-
#simpleCountingModeLabel {
text: "tutti.editSpeciesFrequencies.label.no.configuration";
horizontalAlignment: {JLabel.CENTER};
@@ -250,6 +214,53 @@
bean: {model};
}
+#dataInFrequenciesWarningContainer {
+ background: {new java.awt.Color(245, 218, 88)};
+ visible: {(model.getRowsInError().size() + model.getEmptyRows().size()) != model.getRows().size()};
+}
+
+#dataInFrequenciesWarning {
+ actionIcon: warning;
+ border: {new javax.swing.border.EmptyBorder(5, 10, 5, 10)};
+ text: "tutti.editSpeciesFrequencies.simpleCountingAndFrequencies";
+}
+
+#simpleModeButton {
+ text: "tutti.editSpeciesFrequencies.field.mode.simple";
+ toolTipText: "tutti.editSpeciesFrequencies.field.mode.simple.tip";
+ value: "simpleMode";
+ selected: {model.isSimpleMode()};
+ buttonGroup: "mode";
+ _help: {"tutti.editSpeciesFrequencies.field.mode.simple.help"};
+}
+
+#autoGenModeButton {
+ text: "tutti.editSpeciesFrequencies.field.mode.autoGen";
+ toolTipText: "tutti.editSpeciesFrequencies.field.mode.autoGen.tip";
+ value: "autoGenMode";
+ selected: {model.isAutoGenMode()};
+ buttonGroup: "mode";
+ _help: {"tutti.editSpeciesFrequencies.field.mode.autoGen.help"};
+}
+
+#rafaleModeButton {
+ text: "tutti.editSpeciesFrequencies.field.mode.rafale";
+ toolTipText: "tutti.editSpeciesFrequencies.field.mode.rafale.tip";
+ value: "rafaleMode";
+ selected: {model.isRafaleMode()};
+ buttonGroup: "mode";
+ _help: {"tutti.editSpeciesFrequencies.field.mode.rafale.help"};
+}
+
+#simpleCountingModeButton {
+ text: "tutti.editSpeciesFrequencies.field.mode.simpleCounting";
+ toolTipText: "tutti.editSpeciesFrequencies.field.mode.simpleCounting.tip";
+ value: "simpleCountingMode";
+ selected: {model.isSimpleCountingMode()};
+ buttonGroup: "mode";
+ _help: {"tutti.editSpeciesFrequencies.field.mode.simpleCounting.help"};
+}
+
#generateButton {
actionIcon: generate;
text: "tutti.editSpeciesFrequencies.action.generate";
@@ -285,13 +296,3 @@
_help: {"tutti.editSpeciesFrequencies.action.saveAndClose.help"};
}
-#dataInFrequenciesWarningContainer {
- background: {new java.awt.Color(245, 218, 88)};
- visible: {(model.getRowsInError().size() + model.getEmptyRows().size()) != model.getRows().size()};
-}
-
-#dataInFrequenciesWarning {
- actionIcon: warning;
- border: {new javax.swing.border.EmptyBorder(5, 10, 5, 10)};
- text: "tutti.editSpeciesFrequencies.simpleCountingAndFrequencies";
-}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-09-24 13:30:43 UTC (rev 1219)
@@ -322,7 +322,6 @@
addFloatColumnToModel(columnModel,
SpeciesFrequencyTableModel.WEIGHT,
- TuttiUI.DECIMAL3_PATTERN,
weightUnit);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-09-24 13:30:43 UTC (rev 1219)
@@ -393,7 +393,6 @@
addFloatColumnToModel(columnModel,
SplitSpeciesBatchTableModel.WEIGHT,
- TuttiUI.DECIMAL3_PATTERN,
getConfig().getSpeciesWeightUnit());
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-09-24 13:30:43 UTC (rev 1219)
@@ -39,6 +39,7 @@
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionUI;
import fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachment;
import fr.ifremer.tutti.ui.swing.util.editor.SimpleTimeEditor;
+import fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataEditor;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
import jaxx.runtime.JAXXUtil;
import jaxx.runtime.SwingUtil;
@@ -445,6 +446,20 @@
String tip = weightUnit.decorateTip(jLabel.getToolTipText());
jLabel.setToolTipText(tip);
+
+ Component labelFor = jLabel.getLabelFor();
+ if (labelFor instanceof TuttiComputedOrNotDataEditor) {
+
+ // set also the number of digits (4 for kg, 1 for g)
+ TuttiComputedOrNotDataEditor editor = (TuttiComputedOrNotDataEditor) labelFor;
+ editor.setNumberPattern(weightUnit.getNumberEditorPattern());
+ editor.setDecimalNumber(weightUnit.getNumberDigits());
+ } else if (labelFor instanceof NumberEditor) {
+
+ // set also the number of digits (4 for kg, 1 for g)
+ NumberEditor editor = (NumberEditor) labelFor;
+ editor.setNumberPattern(weightUnit.getNumberEditorPattern());
+ }
}
}
@@ -882,16 +897,30 @@
addColumnToModel(model, editor, null, identifier, null);
}
+// protected <R extends AbstractTuttiBeanUIModel> void addFloatColumnToModel(TableColumnModel model,
+// ColumnIdentifier<R> identifier,
+// String numberPattern,
+// WeightUnit weightUnit) {
+//
+// NumberCellEditor<Float> editor =
+// JAXXWidgetUtil.newNumberTableCellEditor(Float.class, false);
+// editor.getNumberEditor().setSelectAllTextOnError(true);
+// editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2));
+// editor.getNumberEditor().setNumberPattern(numberPattern);
+//
+// addColumnToModel(model, editor, null, identifier, weightUnit);
+// }
+
protected <R extends AbstractTuttiBeanUIModel> void addFloatColumnToModel(TableColumnModel model,
ColumnIdentifier<R> identifier,
- String numberPattern,
WeightUnit weightUnit) {
+ Preconditions.checkNotNull(weightUnit);
NumberCellEditor<Float> editor =
JAXXWidgetUtil.newNumberTableCellEditor(Float.class, false);
editor.getNumberEditor().setSelectAllTextOnError(true);
editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2));
- editor.getNumberEditor().setNumberPattern(numberPattern);
+ editor.getNumberEditor().setNumberPattern(weightUnit.getNumberEditorPattern());
addColumnToModel(model, editor, null, identifier, weightUnit);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUI.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUI.java 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUI.java 2013-09-24 13:30:43 UTC (rev 1219)
@@ -122,6 +122,14 @@
public static final String DECIMAL3_PATTERN = "\\d{0,6}(\\.\\d{0,3})?";
/**
+ * Pattern to use for decimal numeric values with 4 decimal digits in
+ * editors.
+ *
+ * @since 2.6
+ */
+ public static final String DECIMAL4_PATTERN = "\\d{0,6}(\\.\\d{0,4})?";
+
+ /**
* Pattern to use for decimal numeric values with 2 digits + 3 decimal digits in
* editors.
*
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/WeightUnit.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/WeightUnit.java 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/WeightUnit.java 2013-09-24 13:30:43 UTC (rev 1219)
@@ -36,7 +36,7 @@
* @since 2.5
*/
public enum WeightUnit {
- G(n_("tutti.common.unit.g"), n_("tutti.common.unit.short.g")) {
+ G(n_("tutti.common.unit.g"), n_("tutti.common.unit.short.g"), 1, TuttiUI.DECIMAL1_PATTERN) {
@Override
public Float fromEntity(Float weight) {
return weight == null ? null : weight * 1000;
@@ -47,7 +47,7 @@
return weight == null ? null : weight / 1000.0f;
}
},
- KG(n_("tutti.common.unit.kg"), n_("tutti.common.unit.short.kg")) {
+ KG(n_("tutti.common.unit.kg"), n_("tutti.common.unit.short.kg"), 4, TuttiUI.DECIMAL4_PATTERN) {
@Override
public Float fromEntity(Float weight) {
return weight;
@@ -63,9 +63,15 @@
private final String i18nKey;
- WeightUnit(String i18nKey, String i18nShortKey) {
+ private final int numberDigits;
+
+ private final String numberEditorPattern;
+
+ WeightUnit(String i18nKey, String i18nShortKey, int numberDigits, String numberEditorPattern) {
this.i18nKey = i18nKey;
this.i18nShortKey = i18nShortKey;
+ this.numberDigits = numberDigits;
+ this.numberEditorPattern = numberEditorPattern;
}
public String getLabel() {
@@ -76,6 +82,14 @@
return _(i18nShortKey);
}
+ public int getNumberDigits() {
+ return numberDigits;
+ }
+
+ public String getNumberEditorPattern() {
+ return numberEditorPattern;
+ }
+
/**
* Transform the given {@code weight} coming from db to ui.
*
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java 2013-09-24 11:19:17 UTC (rev 1218)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java 2013-09-24 13:30:43 UTC (rev 1219)
@@ -27,6 +27,7 @@
import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.WeightUnit;
import jaxx.runtime.JAXXUtil;
import javax.swing.AbstractCellEditor;
@@ -53,26 +54,27 @@
* @since 1.0
*/
public class TuttiComputedOrNotDataTableCell extends DefaultTableCellRenderer {
+ private static final long serialVersionUID = 1L;
public static TableCellRenderer newRender(TableCellRenderer renderer,
- boolean useFloat,
- Integer decimalNumber,
+ WeightUnit weightUnit,
Color computedDataColor) {
return new TuttiComputedOrNotDataTableCellRenderer(renderer,
- useFloat,
- decimalNumber,
+ true,
+ weightUnit.getNumberDigits(),
computedDataColor);
}
public static TableCellEditor newEditor(Class type,
- boolean useSign,
- boolean useFloat,
- Integer decimalNumber,
+ WeightUnit weightUnit,
Color computedDataColor) {
- return new TuttiComputedOrNotDataTableCellEditor(type, useSign,
- useFloat, decimalNumber,
+ return new TuttiComputedOrNotDataTableCellEditor(type,
+ false,
+ true,
+ weightUnit.getNumberDigits(),
+ weightUnit.getNumberEditorPattern(),
computedDataColor);
}
@@ -91,6 +93,7 @@
boolean useSign,
boolean useFloat,
Integer decimalNumber,
+ String numberPattern,
Color computedDataColor) {
numberEditor = new TuttiComputedOrNotDataEditor();
@@ -100,8 +103,8 @@
numberEditor.getTextField().addAncestorListener(this);
numberEditor.getTextField().setBorder(new LineBorder(Color.GRAY, 2));
numberEditor.setSelectAllTextOnError(true);
- numberEditor.setNumberPattern(TuttiUI.DECIMAL3_PATTERN);
+ numberEditor.setNumberPattern(numberPattern);
numberEditor.setModelType(type);
numberEditor.setUseSign(useSign);
numberEditor.setUseFloat(useFloat);
@@ -179,7 +182,7 @@
}
}
- public static class TuttiComputedOrNotDataTableCellRenderer<E>
+ public static class TuttiComputedOrNotDataTableCellRenderer
implements TableCellRenderer {
protected final TableCellRenderer delegate;
1
0
r1218 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches
by tchemit@users.forge.codelutin.com 24 Sep '13
by tchemit@users.forge.codelutin.com 24 Sep '13
24 Sep '13
Author: tchemit
Date: 2013-09-24 13:19:17 +0200 (Tue, 24 Sep 2013)
New Revision: 1218
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1218
Log:
fixes #3341: [CAPTURE] manque l'unit?\195?\169 kg sur onglet R?\195?\169sum?\195?\169 boite Capture (poids total, poids total vrac etc.)
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-09-23 16:25:28 UTC (rev 1217)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-09-24 11:19:17 UTC (rev 1218)
@@ -90,6 +90,7 @@
labelFor: {catchTotalWeightField};
_strongStyle: true;
_help: {"tutti.editCatchBatch.field.catchTotalWeight.help"};
+ _addWeightUnit: {model.getCatchWeightUnit()};
}
#catchTotalSortedWeightPanel {
@@ -106,6 +107,7 @@
toolTipText: {"tutti.editCatchBatch.field.catchTotalSortedWeight.tip"};
labelFor: {catchTotalSortedWeightField};
_help: {"tutti.editCatchBatch.field.catchTotalSortedWeight.help"};
+ _addWeightUnit: {model.getCatchWeightUnit()};
}
#catchTotalSortedWeightField {
@@ -122,6 +124,7 @@
toolTipText: {"tutti.editCatchBatch.field.catchTotalSortedTremisWeight.tip"};
labelFor: {catchTotalSortedTremisWeightField};
_help: {"tutti.editCatchBatch.field.catchTotalSortedTremisWeight.help"};
+ _addWeightUnit: {model.getCatchWeightUnit()};
}
#catchTotalSortedTremisWeightField {
@@ -134,6 +137,7 @@
toolTipText: {"tutti.editCatchBatch.field.catchTotalSortedCarousselWeight.tip"};
labelFor: {catchTotalSortedCarousselWeightField};
_help: {"tutti.editCatchBatch.field.catchTotalSortedCarousselWeight.help"};
+ _addWeightUnit: {model.getCatchWeightUnit()};
}
#catchTotalSortedCarousselWeightField {
@@ -146,6 +150,7 @@
toolTipText: {"tutti.editCatchBatch.field.catchTotalRejectedWeight.tip"};
labelFor: {catchTotalRejectedWeightField};
_help: {"tutti.editCatchBatch.field.catchTotalRejectedWeight.help"};
+ _addWeightUnit: {model.getCatchWeightUnit()};
}
#catchTotalRejectedWeightField {
@@ -158,6 +163,7 @@
toolTipText: {"tutti.editCatchBatch.field.catchTotalUnsortedWeight.tip"};
labelFor: {catchTotalUnsortedWeightField};
_help: {"tutti.editCatchBatch.field.catchTotalUnsortedWeight.help"};
+ _addWeightUnit: {model.getCatchWeightUnit()};
}
#catchTotalUnsortedWeightField {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-09-23 16:25:28 UTC (rev 1217)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-09-24 11:19:17 UTC (rev 1218)
@@ -58,7 +58,6 @@
import static org.nuiton.i18n.I18n.n_;
/**
- * //FIXME Do weightUnit conversion...
* @author tchemit <chemit(a)codelutin.com>
* @since 0.3
*/
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2013-09-23 16:25:28 UTC (rev 1217)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2013-09-24 11:19:17 UTC (rev 1218)
@@ -174,7 +174,12 @@
WeightUnit individualObservationWeightUnit) {
super(CatchBatch.class, fromBeanBinder, toBeanBinder);
//FIXME See if this can be configurable or guess from other weightUnits
- this.catchWeightUnit = WeightUnit.KG;
+ if (WeightUnit.G == speciesWeightUnit &&
+ WeightUnit.G == benthosWeightUnit) {
+ this.catchWeightUnit = WeightUnit.G;
+ } else {
+ this.catchWeightUnit = WeightUnit.KG;
+ }
this.speciesWeightUnit = speciesWeightUnit;
this.benthosWeightUnit = benthosWeightUnit;
this.marineLitterWeightUnit = marineLitterWeightUnit;
@@ -203,6 +208,10 @@
PROPERTY_CATCH_TOTAL_REJECTED_WEIGHT, this);
}
+ public WeightUnit getCatchWeightUnit() {
+ return catchWeightUnit;
+ }
+
public boolean isLoadingData() {
return loadingData;
}
1
0
Author: tchemit
Date: 2013-09-23 18:25:28 +0200 (Mon, 23 Sep 2013)
New Revision: 1217
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1217
Log:
fix for maven 3
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-09-23 16:11:33 UTC (rev 1216)
+++ trunk/pom.xml 2013-09-23 16:25:28 UTC (rev 1217)
@@ -609,7 +609,7 @@
</profile>
<profile>
- <id>deploy-legacy-tutti-application-update</id>
+ <id>deploy-update-tutti-update</id>
<activation>
<property>
<name>performRelease</name>
@@ -624,7 +624,7 @@
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
- <id>copy tutti-application.properties to site</id>
+ <id>copy update-tutti.properties to site</id>
<phase>package</phase>
<inherited>false</inherited>
<configuration>
@@ -655,6 +655,7 @@
<version>1.0-beta-4</version>
<executions>
<execution>
+ <id>deploy update-tutti.properties</id>
<phase>deploy</phase>
<inherited>false</inherited>
<goals>
@@ -724,6 +725,7 @@
<version>1.0-beta-4</version>
<executions>
<execution>
+ <id>deploy tutti-application.properties</id>
<phase>deploy</phase>
<inherited>false</inherited>
<goals>
@@ -792,6 +794,7 @@
<version>1.0-beta-4</version>
<executions>
<execution>
+ <id>deploy tutti-db.properties</id>
<phase>deploy</phase>
<inherited>false</inherited>
<goals>
1
0
The Tutti team is pleased to announce the tutti-2.5.1 release!
Outil de saisie de données d'opérations et de captures au
cours des campagnes halieutiques.
Documentation of the project can be found here:
http://forge.codelutin.com/projects/tutti
Changes
-------
Changes in this version include:
Fixed Bugs:
o [données individuelles] erreur à l'enregistrement pour la cration d'une nouvelle ligne Issue: 3321. Thanks to Vincent BADTS. Resolved by tchemit.
Changes:
o [TECH] Mettre à jour l'ancien fichier des mises à jour Issue: 3323. Thanks to Tony Chemit. Resolved by tchemit.
Downloads
---------
No release file deployed. (all files are deployed in the maven repository)
Maven artifacts
---------------
Artifacts are deployed in nuiton maven repository
http://maven.nuiton.org/other-releases/
Have fun!
-Tutti team
1
0
r1216 - in trunk: . tutti-persistence tutti-service tutti-ui-swing
by maven-release@users.forge.codelutin.com 23 Sep '13
by maven-release@users.forge.codelutin.com 23 Sep '13
23 Sep '13
Author: maven-release
Date: 2013-09-23 18:11:33 +0200 (Mon, 23 Sep 2013)
New Revision: 1216
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1216
Log:
[maven-release-plugin] prepare for next development iteration
Modified:
trunk/pom.xml
trunk/tutti-persistence/pom.xml
trunk/tutti-service/pom.xml
trunk/tutti-ui-swing/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-09-23 16:11:23 UTC (rev 1215)
+++ trunk/pom.xml 2013-09-23 16:11:33 UTC (rev 1216)
@@ -32,7 +32,7 @@
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>2.5.1</version>
+ <version>2.6-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Tutti</name>
@@ -86,12 +86,12 @@
</modules>
<scm>
- <url>http://svn.forge.codelutin.com/svn/tutti/tags/tutti-2.5.1</url>
+ <url>http://svn.forge.codelutin.com/svn/tutti/trunk</url>
<connection>
- scm:svn:http://svn.forge.codelutin.com/svn/tutti/tags/tutti-2.5.1
+ scm:svn:http://svn.forge.codelutin.com/svn/tutti/trunk
</connection>
<developerConnection>
- scm:svn:http://svn.forge.codelutin.com/svn/tutti/tags/tutti-2.5.1
+ scm:svn:http://svn.forge.codelutin.com/svn/tutti/trunk
</developerConnection>
</scm>
<distributionManagement>
Modified: trunk/tutti-persistence/pom.xml
===================================================================
--- trunk/tutti-persistence/pom.xml 2013-09-23 16:11:23 UTC (rev 1215)
+++ trunk/tutti-persistence/pom.xml 2013-09-23 16:11:33 UTC (rev 1216)
@@ -27,7 +27,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>2.5.1</version>
+ <version>2.6-SNAPSHOT</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
Modified: trunk/tutti-service/pom.xml
===================================================================
--- trunk/tutti-service/pom.xml 2013-09-23 16:11:23 UTC (rev 1215)
+++ trunk/tutti-service/pom.xml 2013-09-23 16:11:33 UTC (rev 1216)
@@ -27,7 +27,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>2.5.1</version>
+ <version>2.6-SNAPSHOT</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
Modified: trunk/tutti-ui-swing/pom.xml
===================================================================
--- trunk/tutti-ui-swing/pom.xml 2013-09-23 16:11:23 UTC (rev 1215)
+++ trunk/tutti-ui-swing/pom.xml 2013-09-23 16:11:33 UTC (rev 1216)
@@ -27,7 +27,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>2.5.1</version>
+ <version>2.6-SNAPSHOT</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
1
0
Author: maven-release
Date: 2013-09-23 18:11:23 +0200 (Mon, 23 Sep 2013)
New Revision: 1215
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1215
Log:
[maven-release-plugin] copy for tag tutti-2.5.1
Added:
tags/tutti-2.5.1/
1
0