This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See http://git.codelutin.com/observe.git commit 248c1f68bd20115e5fd9d882839399613c84d765 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Mon Sep 28 09:55:57 2015 +0200 mise en place du générateur de text (refs #7547) --- observe-application-swing/pom.xml | 6 + .../java/fr/ird/observe/ObserveTextGenerator.java | 106 +++++++ .../observe/ui/actions/ShowStorageInfoAction.java | 13 +- .../ird/observe/ui/storage/StorageUIHandler.java | 350 +-------------------- .../fr/ird/observe/ui/storage/tabs/ConfigUI.css | 5 +- .../fr/ird/observe/ui/storage/tabs/ConfigUI.jaxx | 3 +- .../ui/storage/tabs/StorageTabUIHandler.java | 37 +-- .../main/resources/ftl/connexionTestResult_fr.ftl | 20 ++ .../ftl/dataSourceConnectionReport_fr.ftl | 348 ++++++++++++++++++++ .../resources/ftl/dataSourceInformation_fr.ftl | 54 ++++ .../ftl/dataSourceSelectModeResume_fr.ftl | 40 +++ .../ftl/storageModelDataSourceConfiguration_fr.ftl | 18 ++ .../observe-application-swing_en_GB.properties | 1 + .../observe-application-swing_es_ES.properties | 1 + .../observe-application-swing_fr_FR.properties | 1 + pom.xml | 7 + 16 files changed, 623 insertions(+), 387 deletions(-) diff --git a/observe-application-swing/pom.xml b/observe-application-swing/pom.xml index 4c2464d..783b8f8 100644 --- a/observe-application-swing/pom.xml +++ b/observe-application-swing/pom.xml @@ -232,6 +232,12 @@ <artifactId>jxlayer</artifactId> </dependency> + <!-- FreeMarker --> + <dependency> + <groupId>org.freemarker</groupId> + <artifactId>freemarker</artifactId> + </dependency> + <!-- Map --> <dependency> <groupId>org.geotools</groupId> diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ObserveTextGenerator.java b/observe-application-swing/src/main/java/fr/ird/observe/ObserveTextGenerator.java new file mode 100644 index 0000000..d06f59b --- /dev/null +++ b/observe-application-swing/src/main/java/fr/ird/observe/ObserveTextGenerator.java @@ -0,0 +1,106 @@ +package fr.ird.observe; + +import fr.ird.observe.db.ObserveSwingDataSource; +import fr.ird.observe.services.configuration.ObserveDataSourceConfiguration; +import fr.ird.observe.ui.storage.StorageUIModel; +import freemarker.cache.ClassTemplateLoader; +import freemarker.template.Configuration; +import freemarker.template.Template; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.i18n.I18n; +import org.nuiton.jaxx.application.ApplicationTechnicalException; + +import java.io.StringWriter; +import java.io.Writer; +import java.util.Locale; + +import static org.nuiton.i18n.I18n.t; + +/** + * @author Sylvain Bavencoff - bavencoff@codelutin.com + */ +public class ObserveTextGenerator { + + private static final Log log = LogFactory.getLog(ObserveTextGenerator.class); + + protected static final ObserveTextGenerator currentInstance = new ObserveTextGenerator(); + + public static ObserveTextGenerator get() { + return currentInstance; + } + + protected static final String DATA_SOURCE_CONFIGURATION_TEMPLATE = "dataSourceConfiguration.ftl"; + + protected static final String CONNEXION_TEST_RESULT_TEMPLATE = "connexionTestResult.ftl"; + + protected static final String DATA_SOURCE_SELECT_MODE_RESUME_TEMPLATE = "dataSourceSelectModeResume.ftl"; + + protected static final String DATA_SOURCE_CONNECTION_REPORT_TEMPLATE = "dataSourceConnectionReport.ftl"; + + protected static final String DATA_SOURCE_INFORMATION_TEMPLATE = "dataSourceInformation.ftl"; + + + protected final Configuration freemarkerConfiguration; + + private ObserveTextGenerator() { + freemarkerConfiguration = new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS); + + // needed to overwrite "Defaults to default system encoding." + // fix encoding issue on some systems + freemarkerConfiguration.setEncoding(Locale.getDefault(), "UTF-8"); + + // specific template loader to get template from jars (classpath) + ClassTemplateLoader templateLoader = new ClassTemplateLoader(ObserveTextGenerator.class, "/ftl"); + freemarkerConfiguration.setTemplateLoader(templateLoader); + +// freemarkerConfiguration.setObjectWrapper(new BeansWrapper(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS)); + } + + public String getConfigurationDetail(ObserveDataSourceConfiguration dataSourceConfiguration) { + return generateHtml(DATA_SOURCE_CONFIGURATION_TEMPLATE, dataSourceConfiguration); + } + + public String getConnexionTestResultMessage(StorageUIModel model) { + return generateHtml(CONNEXION_TEST_RESULT_TEMPLATE, model); + } + + public String getLoadDataSourceResume(StorageUIModel model) { + return generateHtml(DATA_SOURCE_SELECT_MODE_RESUME_TEMPLATE, model); + } + + public String getDataSourceConnectionReport(StorageUIModel model) { + return generateHtml(DATA_SOURCE_CONNECTION_REPORT_TEMPLATE, model); + } + + public String getDataSourceInfo(ObserveSwingDataSource source) { + return generateHtml(DATA_SOURCE_INFORMATION_TEMPLATE, source); + } + + protected String generateHtml(String templateName, Object model) { + return generateHtml(I18n.getDefaultLocale(), templateName, model); + } + + protected String generateHtml(Locale locale, String templateName, Object model) { + + try { + + // Get freemarker template + Template mapTemplate = freemarkerConfiguration.getTemplate(templateName, locale); + + Writer out = new StringWriter(); + mapTemplate.process(model, out); + + out.flush(); + + return out.toString(); + + + } catch (Exception ex) { + if (log.isErrorEnabled()) { + log.error("error while generating html", ex); + } + throw new ApplicationTechnicalException(t("observe.generateHtml.error", templateName), ex); + } + } +} diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowStorageInfoAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowStorageInfoAction.java index 346fd9e..e1cc041 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowStorageInfoAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowStorageInfoAction.java @@ -23,9 +23,12 @@ package fr.ird.observe.ui.actions; */ import fr.ird.observe.ObserveSwingApplicationContext; +import fr.ird.observe.ObserveTextGenerator; +import fr.ird.observe.db.ObserveSwingDataSource; import jaxx.runtime.SwingUtil; import fr.ird.observe.ui.*; import javax.swing.AbstractAction; +import javax.swing.JLabel; import javax.swing.JOptionPane; import java.awt.event.ActionEvent; @@ -55,15 +58,17 @@ public class ShowStorageInfoAction extends AbstractAction { @Override public void actionPerformed(ActionEvent e) { - String text; + ObserveSwingDataSource source; if (ui.getConfig().isMainStorageOpened()) { - text = ObserveSwingApplicationContext.get().getDataSource().toString(); + source = ObserveSwingApplicationContext.get().getDataSource(); } else { - text = t("observe.message.db.none.loaded"); + source = null; } + + String text = ObserveTextGenerator.get().getDataSourceInfo(source); JOptionPane.showMessageDialog( ui, - text, + new JLabel(text), t("observe.title.storage.info"), JOptionPane.INFORMATION_MESSAGE); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java index dbdf8db..0cd4773 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java @@ -27,7 +27,7 @@ import com.google.common.collect.Iterables; import fr.ird.observe.ObserveActionExecutor; import fr.ird.observe.ObserveRunner; import fr.ird.observe.ObserveSwingApplicationContext; -import fr.ird.observe.ui.DecoratorService; +import fr.ird.observe.ObserveTextGenerator; import fr.ird.observe.business.db.DataSource; import fr.ird.observe.business.db.DataSourceException; import fr.ird.observe.business.util.SecurityModel; @@ -45,6 +45,7 @@ import fr.ird.observe.services.dto.DataSourceCreateConfigurationDto; import fr.ird.observe.services.dto.IdDto; import fr.ird.observe.services.dto.IdDtos; import fr.ird.observe.services.service.DataSourceDumpProducerService; +import fr.ird.observe.ui.DecoratorService; import fr.ird.observe.ui.ObserveMainUI; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.storage.tabs.DataSelectionModel; @@ -666,35 +667,8 @@ public class StorageUIHandler { log.debug("Build report from step " + step); } StorageUIModel model = ui.getModel(); - DbMode dbMode = model.getDbMode(); - if (dbMode == null) { - return ""; - } - SelectDataUI selectDataUI = (SelectDataUI) - ui.getStepUI(StorageStep.SELECT_DATA); - - StringBuilder sb = new StringBuilder(512); - if (model.isBackupAction()) { - - computeBackupReport(selectDataUI, model, sb); - } else { - switch (model.getDbMode()) { - - case USE_LOCAL: - computeConnectLocalReport(model, sb); - break; - case CREATE_LOCAL: - computeCreateLocalReport(model, sb); - break; - case USE_REMOTE: - computeConnectRemoteReport(selectDataUI, model, sb); - break; - case USE_SERVER: - computeConnectServerReport(selectDataUI, model, sb); - break; - } - } - return sb.toString(); + String report = ObserveTextGenerator.get().getDataSourceConnectionReport(model); + return report; } public void destroy(StorageUI ui) { @@ -721,292 +695,6 @@ public class StorageUIHandler { return decoratorService; } - protected void computeCreateLocalReport(StorageUIModel model, - StringBuilder sb) { - - // mode de creation - CreationMode creationMode = model.getCreationMode(); - if (creationMode == null) { - return; - } - - if (model.isDoBackup()) { - addTag("h2", sb, t("observe.storage.report.action.backup.local")); - addTag("hr", sb, ""); - - addTag("h3", sb, t("observe.storage.report.selected.backup.file")); - - addOpenTag("ul", sb); - addTag("li", sb, model.getBackupFile().getAbsolutePath()); - addCloseTag("ul", sb); - } - - addTag("h2", sb, t("observe.storage.report.action.create.local")); - addTag("hr", sb, ""); - - switch (creationMode) { - case IMPORT_INTERNAL_DUMP: - addTag("h3", sb, - t("observe.storage.report.action.import.internal")); - addOpenTag("ul", sb); - addTag("li", sb, - model.getConfig().getInitialDbDump().getAbsoluteFile().getAbsolutePath()); - - addCloseTag("ul", sb); - break; - - case IMPORT_EXTERNAL_DUMP: - addTag("h3", sb, - t("observe.storage.report.action.import.backup")); - addOpenTag("ul", sb); - addTag("li", sb, model.getDumpFile().getAbsolutePath()); - addCloseTag("ul", sb); - break; - - /*case IMPORT_LOCAL_STORAGE: - sb.append(t("observe.storage.report.config")+"\n"); - tmpStr = model.getLocalStorageFile().getAbsolutePath(); - sb.append(t("observe.storage.report.selected.localStorageFile",tmpStr)); - break;*/ - case IMPORT_REMOTE_STORAGE: - addTag("h3", sb, - t("observe.storage.report.action.import.remote.referentiel")); - - addTag("pre", sb, model.getDataSourceConfigDetail()); - break; - case IMPORT_SERVER_STORAGE: - addTag("h3", sb, - t("observe.storage.report.action.import.server.referentiel")); - - addTag("pre", sb, model.getDataSourceConfigDetail()); - break; - - case EMPTY: - break; - case IMPORT_LOCAL_STORAGE: - // cas non géré pour le moment - break; - } - - computeCanMigrateAction(model, sb); - } - - protected void computeConnectLocalReport(StorageUIModel model, - StringBuilder sb) { - - addTag("h2", sb, t("observe.storage.report.action.connect.local")); - addTag("hr", sb, ""); - - addTag("h3", sb, t("observe.storage.report.selected.localStorageFile")); - addOpenTag("ul", sb); - addTag("li", sb, - model.getH2Config().getDirectory().getAbsolutePath() - ); - addCloseTag("ul", sb); - - computeCanMigrateAction(model, sb); - } - - protected void computeConnectRemoteReport(SelectDataUI tabUI, - StorageUIModel model, - StringBuilder sb) { - - ObstunaAdminAction action = model.getAdminAction(); - if (action == null) { - addTag("h2", sb, t("observe.storage.report.action.connect.remote")); - addTag("hr", sb, ""); - - addTag("h3", sb, t("observe.storage.report.selected.remoteStorage")); - - addTag("pre", sb, model.getPgConfig().toString()); - - computeCanMigrateAction(model, sb); - } else { - addTag("h2", sb, t(action.getLabel())); - addTag("hr", sb, ""); - - addTag("h3", sb, t("observe.storage.report.selected.remoteStorage")); - addTag("pre", sb, model.getPgConfig().toString()); - - if (ObstunaAdminAction.CREATE == action) { - - if (model.isImportReferentiel()) { - switch (model.getReferentielImportMode()) { - - case IMPORT_EXTERNAL_DUMP: - addTag("h3", sb, - t("observe.storage.report.action.referentiel.import.backup")); - addOpenTag("ul", sb); - addTag("li", sb, model.getCentralSourceModel().getDumpFile().getAbsolutePath()); - addCloseTag("ul", sb); - break; - - case IMPORT_REMOTE_STORAGE: - addTag("h3", sb, - t("observe.storage.report.action.import.remote.referentiel")); - addTag("pre", sb, model.getCentralSourceModel().getPgConfig().toString()); - break; - - case IMPORT_SERVER_STORAGE: - addTag("h3", sb, - t("observe.storage.report.action.import.server.referentiel")); - addTag("pre", sb, model.getCentralSourceModel().getRestConfig().toString()); - break; - } - - } else { - - addTag("h3", sb, - t("observe.storage.report.action.no.referentiel.import")); - - } - - if (model.isImportData()) { - - switch (model.getDataImportMode()) { - - case IMPORT_EXTERNAL_DUMP: - addTag("h3", sb, - t("observe.storage.report.action.data.import.backup")); - addOpenTag("ul", sb); - addTag("li", sb, model.getDataSourceModel().getDumpFile().getAbsolutePath()); - addCloseTag("ul", sb); - break; - - case IMPORT_REMOTE_STORAGE: - addTag("h3", sb, - t("observe.storage.report.action.import.remote.data")); - addTag("pre", sb, model.getDataSourceModel().getPgConfig().toString()); - break; - - case IMPORT_SERVER_STORAGE: - addTag("h3", sb, - t("observe.storage.report.action.import.server.data")); - addTag("pre", sb, model.getDataSourceModel().getRestConfig().toString()); - break; - } - - try { - computeImportDataReport(model, sb); - } catch (DataSourceException e) { - throw new RuntimeException("Could not render data to import", e); - } - - } else { - - addTag("h3", sb, - t("observe.storage.report.action.no.data.import")); - - } - - } else { - computeCanMigrateAction(model, sb); - } - - computeSecurityreport(model, sb); - } - } - - protected void computeConnectServerReport(SelectDataUI tabUI, - StorageUIModel model, - StringBuilder sb) { - - ObstunaAdminAction action = model.getAdminAction(); - if (action == null) { - addTag("h2", sb, t("observe.storage.report.action.connect.remote")); - addTag("hr", sb, ""); - - addTag("h3", sb, t("observe.storage.report.selected.remoteStorage")); - - addTag("pre", sb, model.getRestConfig().toString()); - - computeCanMigrateAction(model, sb); - } else { - addTag("h2", sb, t(action.getLabel())); - addTag("hr", sb, ""); - - addTag("h3", sb, t("observe.storage.report.selected.remoteStorage")); - addTag("pre", sb, model.getRestConfig().toString()); - - if (ObstunaAdminAction.CREATE == action) { - - if (model.isImportReferentiel()) { - switch (model.getReferentielImportMode()) { - - case IMPORT_EXTERNAL_DUMP: - addTag("h3", sb, - t("observe.storage.report.action.referentiel.import.backup")); - addOpenTag("ul", sb); - addTag("li", sb, model.getCentralSourceModel().getDumpFile().getAbsolutePath()); - addCloseTag("ul", sb); - break; - - case IMPORT_REMOTE_STORAGE: - addTag("h3", sb, - t("observe.storage.report.action.import.remote.referentiel")); - addTag("pre", sb, model.getCentralSourceModel().getPgConfig().toString()); - break; - - case IMPORT_SERVER_STORAGE: - addTag("h3", sb, - t("observe.storage.report.action.import.server.referentiel")); - addTag("pre", sb, model.getCentralSourceModel().getRestConfig().toString()); - break; - } - - } else { - - addTag("h3", sb, - t("observe.storage.report.action.no.referentiel.import")); - - } - - if (model.isImportData()) { - - switch (model.getDataImportMode()) { - - case IMPORT_EXTERNAL_DUMP: - addTag("h3", sb, - t("observe.storage.report.action.data.import.backup")); - addOpenTag("ul", sb); - addTag("li", sb, model.getDataSourceModel().getDumpFile().getAbsolutePath()); - addCloseTag("ul", sb); - break; - - case IMPORT_REMOTE_STORAGE: - addTag("h3", sb, - t("observe.storage.report.action.import.remote.data")); - addTag("pre", sb, model.getDataSourceModel().getPgConfig().toString()); - break; - - case IMPORT_SERVER_STORAGE: - addTag("h3", sb, - t("observe.storage.report.action.import.server.data")); - addTag("pre", sb, model.getDataSourceModel().getRestConfig().toString()); - break; - } - - try { - computeImportDataReport(model, sb); - } catch (DataSourceException e) { - throw new RuntimeException("Could not render data to import", e); - } - - } else { - - addTag("h3", sb, - t("observe.storage.report.action.no.data.import")); - - } - - } else { - computeCanMigrateAction(model, sb); - } - - computeSecurityreport(model, sb); - } - } - protected void computeBackupReport(SelectDataUI stepUI, StorageUIModel model, StringBuilder sb) { @@ -1180,36 +868,6 @@ public class StorageUIHandler { addCloseTag("ul", sb); } - protected void computeCanMigrateAction(StorageUIModel model, StringBuilder sb) { - addTag("h3", sb, t("observe.storage.report.action.migrate") + " :"); - addOpenTag("ul", sb); - if (model.isCanMigrate()) { - Version version = model.getModelVersion(); - addTag("li", sb, t("observe.storage.report.can.migrate", version)); - if (model.isShowMigrationProgression()) { - addTag("li", sb, t("observe.storage.showMigrationProgression")); - } - if (model.isShowMigrationSql()) { - addTag("li", sb, t("observe.storage.showMigrationSql")); - } - } else { - addTag("li", sb, t("observe.storage.report.can.not.migrate")); - } - addCloseTag("ul", sb); - } - - protected void computeSecurityreport(StorageUIModel model, StringBuilder sb) { - - addTag("h3", sb, t("observe.storage.report.selected.security")); - addOpenTag("ul", sb); - SecurityModel security = model.getSecurityModel(); - addTag("li", sb, t("observe.storage.report.security.owner", security.getAdministrateur())); - addTag("li", sb, t("observe.storage.report.security.techniciens", security.getTechnicien())); - addTag("li", sb, t("observe.storage.report.security.readers", security.getUtilisateur())); - addTag("li", sb, t("observe.storage.report.security.referentiels", security.getReferentiel())); - addCloseTag("ul", sb); - } - public static void addTag(String tag, StringBuilder sb, String message) { sb.append('<').append(tag).append('>'); sb.append(message); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/ConfigUI.css b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/ConfigUI.css index 4399f7b..81fb7d4 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/ConfigUI.css +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/ConfigUI.css @@ -134,10 +134,11 @@ } #connexionStatus { - rows:4; - editable:false; + height : 70; focusable:false; font-size:11; + contentType : "text/html"; + editorKit : {new HTMLEditorKit()}; text:{getHandler().updateConnexionStatutText(ConfigUI.this, model.getConnexionStatus())}; _untestedColor:{Color.GRAY}; _successColor:{Color.GREEN}; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/ConfigUI.jaxx b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/ConfigUI.jaxx index aed93d0..97ac53f 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/ConfigUI.jaxx +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/ConfigUI.jaxx @@ -37,6 +37,7 @@ java.io.File javax.swing.border.LineBorder + javax.swing.text.html.HTMLEditorKit static org.nuiton.i18n.I18n.n </import> @@ -271,7 +272,7 @@ public void init() { <row> <cell weightx='1' weighty='1'> <JScrollPane id="connexionStatusPanel"> - <JTextArea id='connexionStatus'/> + <JTextPane id='connexionStatus'/> </JScrollPane> </cell> </row> diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/StorageTabUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/StorageTabUIHandler.java index 7dfa946..5b5b1f7 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/StorageTabUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/StorageTabUIHandler.java @@ -21,6 +21,7 @@ */ package fr.ird.observe.ui.storage.tabs; +import fr.ird.observe.ObserveTextGenerator; import fr.ird.observe.configuration.ObserveSwingApplicationConfig; import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.db.constantes.ConnexionStatus; @@ -29,7 +30,6 @@ import fr.ird.observe.db.constantes.DbMode; import fr.ird.observe.services.configuration.ObserveDataSourceConfiguration; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.storage.StorageStep; -import fr.ird.observe.ui.storage.StorageUIHandler; import fr.ird.observe.ui.storage.StorageUILauncher; import fr.ird.observe.ui.storage.StorageUIModel; import fr.ird.observe.ui.tree.DataSelectionTreeCellRenderer; @@ -99,26 +99,7 @@ public class StorageTabUIHandler { @Override public void propertyChange(PropertyChangeEvent evt) { StorageUIModel model = (StorageUIModel) evt.getSource(); - DbMode dbMode = model.getDbMode(); - CreationMode creationMode = model.getCreationMode(); - StringBuilder sb = new StringBuilder(); - StorageUIHandler.addTag("h3", sb, t("observe.storage.selected.dbMode")); - if (dbMode == null) { - StorageUIHandler.addTag("pre", sb, t("observe.storage.no.dbMode")); - } else { - StorageUIHandler.addTag("pre", sb, t(dbMode.getDescription())); - } - StorageUIHandler.addTag("h3", sb, t("observe.storage.selectedCreationMode")); - if (DbMode.CREATE_LOCAL == dbMode) { - if (creationMode == null) { - StorageUIHandler.addTag("pre", sb, t("observe.storage.no.creationMode")); - } else { - StorageUIHandler.addTag("pre", sb, t(creationMode.getDescription())); - } - } else { - StorageUIHandler.addTag("pre", sb, t("observe.storage.no.creationMode.required")); - } - String txt = sb.toString(); + String txt = ObserveTextGenerator.get().getLoadDataSourceResume(model); ui.getResume().setText(txt); } }; @@ -342,21 +323,9 @@ public class StorageTabUIHandler { } public String updateConnexionStatutText(ConfigUI ui, ConnexionStatus status) { - String text = status.getDescription(); - switch (status) { - case UNTESTED: - text = t(text); - break; - case SUCCESS: - text = t(text, ui.model.getDataSourceConfigDetail()); - break; - case FAILED: - text = t(text, ui.model.getConnexionStatusError()); - break; - } + String text = ObserveTextGenerator.get().getConnexionTestResultMessage(ui.getModel()); return text; } - public void chooseDumpFile(ConfigUI ui) { File f = UIHelper.chooseFile( ui, diff --git a/observe-application-swing/src/main/resources/ftl/connexionTestResult_fr.ftl b/observe-application-swing/src/main/resources/ftl/connexionTestResult_fr.ftl new file mode 100644 index 0000000..f4efabc --- /dev/null +++ b/observe-application-swing/src/main/resources/ftl/connexionTestResult_fr.ftl @@ -0,0 +1,20 @@ +<html> +<body> + <#if connexionStatus.name() == "UNTESTED"> + + <h3>La connexion n'a jamais été validée ou a été modifiée depuis le dernier test de connexion.</h3> + + <#elseif connexionStatus.name() == "FAILED"> + + <h3>La connexion a échouée pour la raison suivante :</h3> + + <ul> + <li>${connexionStatusError}</li> + </ul> + + <#elseif connexionStatus.name() == "SUCCESS"> + Information sur la connexion : + <#include "storageModelDataSourceConfiguration_fr.ftl"> + </#if> +</body> +</html> \ No newline at end of file diff --git a/observe-application-swing/src/main/resources/ftl/dataSourceConnectionReport_fr.ftl b/observe-application-swing/src/main/resources/ftl/dataSourceConnectionReport_fr.ftl new file mode 100644 index 0000000..3d578a4 --- /dev/null +++ b/observe-application-swing/src/main/resources/ftl/dataSourceConnectionReport_fr.ftl @@ -0,0 +1,348 @@ +<html> +<body> + +<#if backupAction> + + <h2> + <#if local> + Sauvegarde de la base locale + <#elseif remote> + Sauvegarde de la base distante + <#elseif server> + Sauvegarde du serveur + </#if> + </h2> + + <hr/> + + <h3> + Emplacement de la sauvegarde : + <ul> + <li>${backupFile.absolutePath}</li> + </ul> + </h3> + + <#if useSelectData && selectDataModel != null> + + <h3>Données à exporter :</h3> + + <ul> + <!--Todo see fr.ird.observe.ui.storage.StorageUIHandler.computeBackupReport--> + <li>Le référentiel sera exporté</li> + </ul> + + </#if> + +<#else> + + <#if dbMode.name() == "USE_LOCAL"> + + <h2>Connection à la base locale</h2> + <hr/> + + <h3>Emplacement de la base locale :</h3> + + <ul> + <li>${h2config.directory.absolutePath}</li> + </ul> + + <#elseif dbMode.name() == "CREATE_LOCAL"> + + <#if doBackup> + + <h2>Sauvegarde de la base locale</h2> + <hr/> + <h3>Emplacement de la sauvegarde :</h3> + <ul> + <li>${backupFile.absolutePath}</li> + </ul> + + </#if> + + <h2>Création de la base locale</h2> + <hr/> + + <#if creationMode.name() == "IMPORT_INTERNAL_DUMP"> + <h3>Import depuis une le dernier référentiel téléchargé :</h3> + + <ul> + <li>${config.initialDbDump.absoluteFile.absolutePath}</li> + </ul> + + <#elseif creationMode.name() == "IMPORT_EXTERNAL_DUMP"> + + <h3>Import depuis une sauvegarde :</h3> + + <ul> + <li>${dumpFile.absolutePath}</li> + </ul> + + <#elseif creationMode.name() == "IMPORT_REMOTE_STORAGE"> + + <h3>Import du référentiel depuis une base distante :</h3> + + <#include "storageModelDataSourceConfiguration.ftl"> + + + <#elseif creationMode.name() == "IMPORT_SERVER_STORAGE"> + + <h3>Import du référentiel depuis un serveur distant :</h3> + + <#include "storageModelDataSourceConfiguration_fr.ftl"> + + </#if> + + + <#elseif dbMode.name() == "USE_REMOTE"> + <#if !adminAction??> + + <h2>Connexion à une base distante</h2> + <hr/> + + <h3>Informations sur la base distante à utiliser :</h3> + + <#include "storageModelDataSourceConfiguration_fr.ftl"> + + <#else> + + <h2>${adminAction.label}</h2> + <hr/> + + <h3>Informations sur la connexion distance à utiliser :</h3> + + <#include "storageModelDataSourceConfiguration_fr.ftl"> + + <#if adminAction.name() == "CREATE"> + + <#if importReferentiel> + + <#if referentielImportMode.name() == "IMPORT_EXTERNAL_DUMP"> + + <h3>Import du référentiel depuis une sauvegarde :</h3> + + <ul> + <li>${centralSourceModel.dumpFile.absolutePath}</li> + </ul> + + <#elseif referentielImportMode.name() == "IMPORT_REMOTE_STORAGE"> + + <h3>Import du référentiel depuis une base distante :</h3> + <ul> + <li><strong>URL jdbc : </strong>${centralSourceModel.pgConfig.jdbcUrl}</li> + <li><strong>Utilisateur : </strong>${centralSourceModel.pgConfig.username}</li> + <li><strong>Mot de passe : </strong>*****</li> + <li><strong>Mode SSL : </strong>${centralSourceModel.pgConfig.useSsl?then('Oui', 'Non')}</li> + </ul> + + <#elseif referentielImportMode.name() == "IMPORT_SERVER_STORAGE"> + + <h3>Import du référentiel depuis un serveur distant :</h3> + <ul> + <li><strong>URL du serveur : </strong>${centralSourceModel.restConfig.serverUrl}</li> + <li><strong>Utilisateur : </strong>${centralSourceModel.restConfig.login}</li> + <li><strong>Mot de passe : </strong>*****</li> + <#if centralSourceModel.restConfig.optionalDatabaseName.present> + <li><strong>Base de données : </strong>${centralSourceModel.restConfig.optionalDatabaseName.get()}</li> + </#if> + </ul> + + </#if> + + <#else> + <h3>Pas d'import de référentiel</h3> + </#if> + + <#if importData> + + <#if referentielImportMode.name() == "IMPORT_EXTERNAL_DUMP"> + + <h3>Import du référentiel depuis une sauvegarde :</h3> + + <ul> + <li>${centralSourceModel.dumpFile.absolutePath}</li> + </ul> + + <#elseif referentielImportMode.name() == "IMPORT_REMOTE_STORAGE"> + + <h3>Import du référentiel depuis une base distante :</h3> + <ul> + <li><strong>URL jdbc : </strong>${centralSourceModel.pgConfig.jdbcUrl}</li> + <li><strong>Utilisateur : </strong>${centralSourceModel.pgConfig.username}</li> + <li><strong>Mot de passe : </strong>*****</li> + <li><strong>Mode SSL : </strong>${centralSourceModel.pgConfig.useSsl?then('Oui', 'Non')}</li> + </ul> + + <#elseif referentielImportMode.name() == "IMPORT_SERVER_STORAGE"> + + <h3>Import du référentiel depuis un serveur distant :</h3> + <ul> + <li><strong>URL du serveur : </strong>${centralSourceModel.restConfig.serverUrl}</li> + <li><strong>Utilisateur : </strong>${centralSourceModel.restConfig.login}</li> + <li><strong>Mot de passe : </strong>*****</li> + <#if centralSourceModel.restConfig.optionalDatabaseName.present> + <li><strong>Base de données : </strong>${centralSourceModel.restConfig.optionalDatabaseName.get()}</li> + </#if> + </ul> + + </#if> + + <#else> + <h3>Pas d'import de données</h3> + + </#if> + + </#if> + + <h3>Sécurité</h3> + <ul> + <li><strong>Propriétaire : : </strong>${securityModel.administrateu}</li> + <li><strong>Techniciens : : </strong>${securityModel.technicien}</li> + <li><strong>Lecteurs : : </strong>${securityModel.utilisateur}</li> + <li><strong>Référentiels : : </strong>${securityModel.referentiel}</li> + </ul> + + + </#if> + + <#elseif dbMode.name() == "USE_SERVER"> + <#if !adminAction??> + + <h2>Connexion à un serveur distant</h2> + <hr/> + + <h3>Informations sur le serveur connexion distant à utiliser :</h3> + + <#include "storageModelDataSourceConfiguration_fr.ftl"> + + <#else> + + <h2>${adminAction.label}</h2> + <hr/> + + <h3>Informations sur le serveur connexion distant à utiliser :</h3> + + <#include "storageModelDataSourceConfiguration_fr.ftl"> + + <#if adminAction.name() == "CREATE"> + + <#if importReferentiel> + + <#if referentielImportMode.name() == "IMPORT_EXTERNAL_DUMP"> + + <h3>Import du référentiel depuis une sauvegarde :</h3> + + <ul> + <li>${centralSourceModel.dumpFile.absolutePath}</li> + </ul> + + <#elseif referentielImportMode.name() == "IMPORT_REMOTE_STORAGE"> + + <h3>Import du référentiel depuis une base distante :</h3> + <ul> + <li><strong>URL jdbc : </strong>${centralSourceModel.pgConfig.jdbcUrl}</li> + <li><strong>Utilisateur : </strong>${centralSourceModel.pgConfig.username}</li> + <li><strong>Mot de passe : </strong>*****</li> + <li><strong>Mode SSL : </strong>${centralSourceModel.pgConfig.useSsl?then('Oui', 'Non')}</li> + </ul> + + <#elseif referentielImportMode.name() == "IMPORT_SERVER_STORAGE"> + + <h3>Import du référentiel depuis un serveur distant :</h3> + <ul> + <li><strong>URL du serveur : </strong>${centralSourceModel.restConfig.serverUrl}</li> + <li><strong>Utilisateur : </strong>${centralSourceModel.restConfig.login}</li> + <li><strong>Mot de passe : </strong>*****</li> + <#if centralSourceModel.restConfig.optionalDatabaseName.present> + <li><strong>Base de données : </strong>${centralSourceModel.restConfig.optionalDatabaseName.get()}</li> + </#if> + </ul> + + </#if> + + <#else> + <h3>Pas d'import de référentiel</h3> + </#if> + + <#if importData> + + <#if referentielImportMode.name() == "IMPORT_EXTERNAL_DUMP"> + + <h3>Import du référentiel depuis une sauvegarde :</h3> + + <ul> + <li>${centralSourceModel.dumpFile.absolutePath}</li> + </ul> + + <#elseif referentielImportMode.name() == "IMPORT_REMOTE_STORAGE"> + + <h3>Import du référentiel depuis une base distante :</h3> + <ul> + <li><strong>URL jdbc : </strong>${centralSourceModel.pgConfig.jdbcUrl}</li> + <li><strong>Utilisateur : </strong>${centralSourceModel.pgConfig.username}</li> + <li><strong>Mot de passe : </strong>*****</li> + <li><strong>Mode SSL : </strong>${centralSourceModel.pgConfig.useSsl?then('Oui', 'Non')}</li> + </ul> + + <#elseif referentielImportMode.name() == "IMPORT_SERVER_STORAGE"> + + <h3>Import du référentiel depuis un serveur distant :</h3> + <ul> + <li><strong>URL du serveur : </strong>${centralSourceModel.restConfig.serverUrl}</li> + <li><strong>Utilisateur : </strong>${centralSourceModel.restConfig.login}</li> + <li><strong>Mot de passe : </strong>*****</li> + <#if centralSourceModel.restConfig.optionalDatabaseName.present> + <li><strong>Base de données : </strong>${centralSourceModel.restConfig.optionalDatabaseName.get()}</li> + </#if> + </ul> + + </#if> + + <#else> + <h3>Pas d'import de données</h3> + + </#if> + + </#if> + + <h3>Sécurité</h3> + <ul> + <li><strong>Propriétaire : : </strong>${securityModel.administrateu}</li> + <li><strong>Techniciens : : </strong>${securityModel.technicien}</li> + <li><strong>Lecteurs : : </strong>${securityModel.utilisateur}</li> + <li><strong>Référentiels : : </strong>${securityModel.referentiel}</li> + </ul> + + </#if> + + </#if> + + <h3>Politique de mise à jour</h3> + + <ul> + + <#if canMigrate> + + <li>Mise à jour si nécessaire (version actuelle : ${modelVersion})</li> + + <#if showMigrationProgression> + + <li>Afficher la progression lors des mises à jour</li> + + </#if> + + <#if showMigrationSql> + + <li>Afficher les requêtes sql lors des mises à jour</li> + + </#if> + + <#else> + + <li>Pas de mise à jour possible</li> + + </#if> + + </ul> +</#if> +</body> +</html> \ No newline at end of file diff --git a/observe-application-swing/src/main/resources/ftl/dataSourceInformation_fr.ftl b/observe-application-swing/src/main/resources/ftl/dataSourceInformation_fr.ftl new file mode 100644 index 0000000..4655558 --- /dev/null +++ b/observe-application-swing/src/main/resources/ftl/dataSourceInformation_fr.ftl @@ -0,0 +1,54 @@ +<html> +<body> + +<#if configuration??> + <h3>${label}</h3> + <ul> + <#if configuration.h2Database??> + <li><strong>Utilisateur : </strong>${configuration.username}</li> + <#elseif configuration.postgresDatabase??> + <li><strong>URL jdbc : </strong>${configuration.jdbcUrl}</li> + <li><strong>Utilisateur : </strong>${configuration.username}</li> + <li><strong>Mode SSL : </strong>${configuration.useSsl?then('Oui', 'Non')}</li> + <#else> + <li><strong>URL du serveur : </strong>${configuration.serverUrl}</li> + <li><strong>Utilisateur : </strong>${configuration.login}</li> + <#if restConfig.optionalDatabaseName.present> + <li><strong>Base de données : </strong>${configuration.optionalDatabaseName.get()}</li> + </#if> + </#if> + </ul> + <h3>Droits</h3> + <li><strong>Référentiel : </strong> + <#if canReadReferential() > + Lecture + <#if canWriteReferential() > + / Ecriture + </#if> + <#elseif canWriteReferential()> + Ecriture + <#else> + Aucun droit + </#if> + </li> + <li><strong>Données observateur : </strong> + <#if canReadData() > + Lecture + <#if canWriteData() > + / Ecriture + </#if> + <#elseif canWriteData() > + Ecriture + <#else> + Aucun droit + </#if> + </li> + </ul> + <h3>Version</h3> + v ${connection.version} +<#else> + Aucune source de données chargée +</#if> + +</body> +</html> \ No newline at end of file diff --git a/observe-application-swing/src/main/resources/ftl/dataSourceSelectModeResume_fr.ftl b/observe-application-swing/src/main/resources/ftl/dataSourceSelectModeResume_fr.ftl new file mode 100644 index 0000000..493779e --- /dev/null +++ b/observe-application-swing/src/main/resources/ftl/dataSourceSelectModeResume_fr.ftl @@ -0,0 +1,40 @@ +<html> +<body> + + <h3>Type de source de données sélectionné</h3> + + <#if dbMode.name() == "USE_LOCAL"> + Utiliser une base locale de type h2 + <#elseif dbMode.name() == "CREATE_LOCAL"> + Creer une base locale de type h2 + <#elseif dbMode.name() == "USE_REMOTE"> + Utiliser une base distante de type postgres + <#elseif dbMode.name() == "USE_SERVER"> + Utiliser un serveur distant + <#else> + Aucun type de source de données sélectionné + </#if> + + <h3>Mode de création sélectionné</h3> + + <#if dbMode.name() == "CREATE_LOCAL"> + <#if !creationMode??> + Aucun mode de création sélectionné + <#elseif creationMode.name() == "EMPTY"> + Générer une nouvelle base locale vide.Cette base n'aura pas de référentiel et il vous faudra ensuite faire un import de référentiel... + <#elseif creationMode.name() == "IMPORT_INTERNAL_DUMP"> + Générer une nouvelle base locale à partir de la dernière version de la base embarquée. + <#elseif creationMode.name() == "IMPORT_EXTERNAL_DUMP"> + Créer une nouvelle base locale à partir d'une précédente sauvegarde de l'application + <#elseif creationMode.name() == "IMPORT_LOCAL_STORAGE"> + Générer une nouvelle base locale et y importer le référentiel d'une autre base locale. + <#elseif creationMode.name() == "IMPORT_REMOTE_STORAGE"> + Générer une nouvelle base locale et y importer le référentiel d'une autre base distante. + <#elseif creationMode.name() == "IMPORT_SERVER_STORAGE"> + Générer une nouvelle base locale et y importer le référentiel d'un serveur distant. + </#if> + <#else> + Non requis. + </#if> +</body> +</html> \ No newline at end of file diff --git a/observe-application-swing/src/main/resources/ftl/storageModelDataSourceConfiguration_fr.ftl b/observe-application-swing/src/main/resources/ftl/storageModelDataSourceConfiguration_fr.ftl new file mode 100644 index 0000000..d1eb1aa --- /dev/null +++ b/observe-application-swing/src/main/resources/ftl/storageModelDataSourceConfiguration_fr.ftl @@ -0,0 +1,18 @@ +<ul> + <#if editRemoteConfig> + <li><strong>URL jdbc : </strong>${pgConfig.jdbcUrl}</li> + <li><strong>Utilisateur : </strong>${pgConfig.username}</li> + <li><strong>Mot de passe : </strong>*****</li> + <li><strong>Mode SSL : </strong>${pgConfig.useSsl?then('Oui', 'Non')}</li> + <#elseif editServerConfig> + <li><strong>URL du serveur : </strong>${restConfig.serverUrl}</li> + <li><strong>Utilisateur : </strong>${restConfig.login}</li> + <li><strong>Mot de passe : </strong>*****</li> + <#if restConfig.optionalDatabaseName.present> + <li><strong>Base de données : </strong>${restConfig.optionalDatabaseName.get()}</li> + </#if> + <#else> + <li><strong>Utilisateur : </strong>${h2Config.username}</li> + <li><strong>Mot de passe : </strong>*****</li> + </#if> +</ul> \ No newline at end of file diff --git a/observe-application-swing/src/main/resources/i18n/observe-application-swing_en_GB.properties b/observe-application-swing/src/main/resources/i18n/observe-application-swing_en_GB.properties index edc8d1e..04ff1c7 100644 --- a/observe-application-swing/src/main/resources/i18n/observe-application-swing_en_GB.properties +++ b/observe-application-swing/src/main/resources/i18n/observe-application-swing_en_GB.properties @@ -1235,6 +1235,7 @@ observe.gearUseFeaturesSeine.table.value=Value observe.gearUseFeaturesSeine.table.value.tip=Caracteristic value observe.gearUseFeaturesSeine.title=Gears observe.gearUseFeaturesSeine.usedInTrip=Used in trip +observe.generateHtml.error= observe.harbour.coordinates= observe.harbour.locode= observe.harbour.name= diff --git a/observe-application-swing/src/main/resources/i18n/observe-application-swing_es_ES.properties b/observe-application-swing/src/main/resources/i18n/observe-application-swing_es_ES.properties index 5fa9165..424014b 100644 --- a/observe-application-swing/src/main/resources/i18n/observe-application-swing_es_ES.properties +++ b/observe-application-swing/src/main/resources/i18n/observe-application-swing_es_ES.properties @@ -1237,6 +1237,7 @@ observe.gearUseFeaturesSeine.table.value= observe.gearUseFeaturesSeine.table.value.tip= observe.gearUseFeaturesSeine.title= observe.gearUseFeaturesSeine.usedInTrip= +observe.generateHtml.error= observe.harbour.coordinates= observe.harbour.locode= observe.harbour.name= diff --git a/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties b/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties index 1ca4299..eb26822 100644 --- a/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties +++ b/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties @@ -1235,6 +1235,7 @@ observe.gearUseFeaturesSeine.table.value=Valeur observe.gearUseFeaturesSeine.table.value.tip=Valeur observe.gearUseFeaturesSeine.title=Équipements observe.gearUseFeaturesSeine.usedInTrip=Utilisé dans la marée +observe.generateHtml.error= observe.harbour.coordinates=Nom observe.harbour.locode=Locode observe.harbour.name=Nom diff --git a/pom.xml b/pom.xml index 7fbc20d..bf54549 100644 --- a/pom.xml +++ b/pom.xml @@ -455,6 +455,13 @@ <classifier>tests</classifier> </dependency> + <!-- FreeMarker --> + <dependency> + <groupId>org.freemarker</groupId> + <artifactId>freemarker</artifactId> + <version>2.3.23</version> + </dependency> + <!-- db --> <dependency> <groupId>com.h2database</groupId> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.