Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: 9ef87e5a by tchemit at 2019-02-08T13:07:00Z Improve boot loading - - - - - 27174660 by tchemit at 2019-02-08T13:26:45Z [UI] Listes déroulantes : ergonomie - See #1202 - - - - - 2 changed files: - client-core/src/main/java/fr/ird/observe/client/ObserveRunner.java - client-core/src/main/java/fr/ird/observe/client/ui/ObserveCommon.jcss Changes: ===================================== client-core/src/main/java/fr/ird/observe/client/ObserveRunner.java ===================================== @@ -53,7 +53,10 @@ import javax.script.ScriptException; import javax.swing.UIManager; import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.Arrays; +import java.util.Comparator; import java.util.Date; import java.util.Locale; import java.util.Properties; @@ -121,47 +124,29 @@ public abstract class ObserveRunner extends ApplicationRunner { I18n.close(); - File i18nDirectory = config.getI18nDirectory(); + Path i18nDirectory = config.getI18nDirectory().toPath(); - UserI18nBootLoader i18nInitializer = new UserI18nBootLoader(i18nDirectory.toPath(), new DefaultI18nBootLoader(I18nConfiguration.createDefaultConfiguration())) { -// -// @Override -// protected void createUserI18nLayout(File directory) throws Exception { -// if (config.getI18nDefinitionFile().exists()) { -// return; -// } -// super.createUserI18nLayout(directory); -// -// // add also a archive with all i18n stupuff (says i18n bundle + templates) -// -// URL resource = ObserveResourceManager.getResource(ObserveResourceManager.OBSERVE_I18N_ARCHIVE); -// File archive = new File(directory.getParent(), ObserveResourceManager.OBSERVE_I18N_ARCHIVE.substring(1)); -// try { -// resourceManager.copyResource(resource, archive, "Copy i18n archive"); -// ZipUtil.uncompressFiltred(archive, directory.getParentFile()); -// } finally { -// if (Files.exists(archive.toPath())) { -// try { -// Files.delete(archive.toPath()); -// } catch (IOException e) { -// log.error(String.format("Could not delete i18n archive %s", archive)); -// } -// } -// } -// -// } - }; + if (config.getBuildVersion().isSnapshot() && Files.exists(i18nDirectory)) { + // always regenerate i18n + try { + Files.walk(i18nDirectory) + .sorted(Comparator.reverseOrder()) + .map(Path::toFile) + .forEach(File::delete); + } catch (IOException e) { + throw new IllegalStateException("Can't delete i18n directory: "+i18nDirectory, e); + } + } + UserI18nBootLoader i18nInitializer = new UserI18nBootLoader(i18nDirectory, new DefaultI18nBootLoader(I18nConfiguration.createDefaultConfiguration())); long t00 = System.nanoTime(); Locale locale = config.getLocale(); I18n.init(i18nInitializer, locale); - if (log.isDebugEnabled()) { log.debug("i18n language : " + locale); log.debug("i18n loading time : " + StringUtil.convertTime(t00, System.nanoTime())); - } } public abstract String getRunnerName(); @@ -217,9 +202,7 @@ public abstract class ObserveRunner extends ApplicationRunner { @Override protected void onInit() throws Exception { - if (log.isInfoEnabled()) { - log.info(t("observe.runner.init", new Date(), Arrays.toString(args))); - } + log.info(t("observe.runner.init", new Date(), Arrays.toString(args))); long t0 = System.nanoTime(); @@ -227,30 +210,22 @@ public abstract class ObserveRunner extends ApplicationRunner { ClientConfig config = initConfig(); - if (log.isInfoEnabled()) { - log.info(t("observe.runner.config.loaded", config.getVersion())); - } + log.info(t("observe.runner.config.loaded", config.getVersion())); // 2 - preparation des répertoires utilisateurs initUserDirectories(config); // 3 - Chargement de la configuration des logs utilisateur - if (!config.isDevMode()) { - initLog(config); - } + initLog(config); - if (log.isInfoEnabled()) { - log.info(t("observe.runner.user.directories.loaded", config.getDataDirectory())); - } + log.info(t("observe.runner.user.directories.loaded", config.getDataDirectory())); // 3 - preparation i18n initI18n(config); - if (log.isInfoEnabled()) { - log.info(t("observe.runner.i18n.loaded", config.getLocale().getDisplayLanguage())); - } + log.info(t("observe.runner.i18n.loaded", config.getLocale().getDisplayLanguage())); // 4 - preparation de la configuration des ui @@ -266,9 +241,7 @@ public abstract class ObserveRunner extends ApplicationRunner { String time = StringUtil.convertTime(t0, System.nanoTime()); - if (log.isInfoEnabled()) { - log.info(t("observe.runner.context.loaded", time)); - } + log.info(t("observe.runner.context.loaded", time)); } private void initLog(ClientConfig config) throws IOException { @@ -287,9 +260,7 @@ public abstract class ObserveRunner extends ApplicationRunner { @Override protected void onStart() throws Exception { - if (log.isInfoEnabled()) { - log.info(t("observe.runner.start", new Date(), Arrays.toString(args))); - } + log.info(t("observe.runner.start", new Date(), Arrays.toString(args))); ObserveSwingApplicationContext context = ObserveSwingApplicationContext.get(); @@ -304,9 +275,7 @@ public abstract class ObserveRunner extends ApplicationRunner { config.get().doAction(ClientConfig.Step.AfterInit.ordinal()); if (!config.isDisplayMainUI()) { - if (log.isInfoEnabled()) { - log.info(t("observe.runner.quit.withno.ui")); - } + log.info(t("observe.runner.quit.withno.ui")); unlock(); return; @@ -320,9 +289,7 @@ public abstract class ObserveRunner extends ApplicationRunner { ObserveMainUI ui = startUI(context, config); - if (log.isInfoEnabled()) { - log.info(t("observe.runner.ui.loaded")); - } + log.info(t("observe.runner.ui.loaded")); Boolean h2ServerMode = ObserveSwingApplicationContext.Entries.H2_SERVER_MODE.get(); @@ -357,18 +324,14 @@ public abstract class ObserveRunner extends ApplicationRunner { protected void onClose(boolean reload) { if (ObserveSwingApplicationContext.isInit()) { - if (log.isDebugEnabled()) { - log.debug("Will close context..."); - } + log.debug("Will close context..."); ObserveSwingApplicationContext.get().close(); } } @Override protected void onShutdown() { - if (log.isInfoEnabled()) { - log.info("ObServe shutdown at " + new Date()); - } + log.info("ObServe shutdown at " + new Date()); try { @@ -392,9 +355,7 @@ public abstract class ObserveRunner extends ApplicationRunner { @Override protected void onShutdown(Exception ex) { - if (log.isErrorEnabled()) { - log.error("error while closing " + ex.getMessage(), ex); - } + log.error("error while closing " + ex.getMessage(), ex); Runtime.getRuntime().halt(1); } @@ -424,9 +385,7 @@ public abstract class ObserveRunner extends ApplicationRunner { File dataDirectory = resourceManager.createDirectory(config, DATA_DIRECTORY); - if (log.isDebugEnabled()) { - log.debug("user data directory : " + dataDirectory); - } + log.debug("user data directory : " + dataDirectory); resourceManager.createParentDirectory(config, DB_DIRECTORY, INITIAL_DB_DUMP); @@ -445,9 +404,7 @@ public abstract class ObserveRunner extends ApplicationRunner { File resourcesDirectory = resourceManager.createDirectory(config, RESOURCES_DIRECTORY); - if (log.isDebugEnabled()) { - log.debug("user resource data directory : " + resourcesDirectory); - } + log.debug("user resource data directory : " + resourcesDirectory); // 5 - application ui @@ -504,18 +461,14 @@ public abstract class ObserveRunner extends ApplicationRunner { boolean hasLocalStorage = new File(config.getLocalDBDirectory(), ClientConfig.DB_NAME).exists(); config.setLocalStorageExist(hasLocalStorage); if (!hasLocalStorage) { - if (log.isInfoEnabled()) { - log.info(t("observe.init.no.local.db.detected", config.getLocalDBDirectory())); - } + log.info(t("observe.init.no.local.db.detected", config.getLocalDBDirectory())); } boolean hasInitialDb = config.getInitialDbDump().exists(); config.setInitialDumpExist(hasInitialDb); if (!hasInitialDb) { - if (log.isInfoEnabled()) { - log.info(t("observe.init.no.initial.dump.detected", config.getInitialDbDump())); - } + log.info(t("observe.init.no.initial.dump.detected", config.getInitialDbDump())); } } @@ -526,13 +479,9 @@ public abstract class ObserveRunner extends ApplicationRunner { UIHelper.initNimbusLoookAndFeel(); } catch (Exception e) { // could not find nimbus look-and-feel - if (log.isWarnEnabled()) { - log.warn(t("observe.warning.nimbus.landf")); - } + log.warn(t("observe.warning.nimbus.landf")); } catch (Throwable e) { - if (log.isWarnEnabled()) { - log.warn(t("observe.warning.no.ui")); - } + log.warn(t("observe.warning.no.ui")); // pas d'environnement d'ui config.setCanUseUI(false); } @@ -562,9 +511,7 @@ public abstract class ObserveRunner extends ApplicationRunner { } } - if (log.isInfoEnabled()) { - log.info(t("observe.runner.loading.ui.configuration", file)); - } + log.info(t("observe.runner.loading.ui.configuration", file)); try { Properties p = resourceManager.getResource(file); UIHelper.loadUIConfig(p); ===================================== client-core/src/main/java/fr/ird/observe/client/ui/ObserveCommon.jcss ===================================== @@ -81,6 +81,7 @@ BeanComboBox { BeanFilterableComboBox { showReset:true; + tabToSelect:false; } BlockingLayerUI { View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/7e31647e36413a6b008d00bab06... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/7e31647e36413a6b008d00bab06... You're receiving this email because of your account on gitlab.com.