Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe

Commits:

3 changed files:

Changes:

  • client-core/src/main/java/fr/ird/observe/client/ObserveRunner.java
    ... ... @@ -53,7 +53,10 @@ import javax.script.ScriptException;
    53 53
     import javax.swing.UIManager;
    
    54 54
     import java.io.File;
    
    55 55
     import java.io.IOException;
    
    56
    +import java.nio.file.Files;
    
    57
    +import java.nio.file.Path;
    
    56 58
     import java.util.Arrays;
    
    59
    +import java.util.Comparator;
    
    57 60
     import java.util.Date;
    
    58 61
     import java.util.Locale;
    
    59 62
     import java.util.Properties;
    
    ... ... @@ -121,47 +124,29 @@ public abstract class ObserveRunner extends ApplicationRunner {
    121 124
     
    
    122 125
             I18n.close();
    
    123 126
     
    
    124
    -        File i18nDirectory = config.getI18nDirectory();
    
    127
    +        Path i18nDirectory = config.getI18nDirectory().toPath();
    
    125 128
     
    
    126
    -        UserI18nBootLoader i18nInitializer = new UserI18nBootLoader(i18nDirectory.toPath(), new DefaultI18nBootLoader(I18nConfiguration.createDefaultConfiguration())) {
    
    127
    -
    
    128
    -//            @Override
    
    129
    -//            protected void createUserI18nLayout(Path directory, I18nLanguageProvider languageProvider) throws Exception {
    
    130
    -//                if (config.getI18nDefinitionFile().exists()) {
    
    131
    -//                    return;
    
    132
    -//                }
    
    133
    -//                super.createUserI18nLayout(directory,languageProvider);
    
    134
    -//
    
    135
    -//                // add also a archive with all i18n stuff (says i18n bundle + templates)
    
    136
    -//
    
    137
    -//                URL resource = ObserveResourceManager.getResource(ObserveResourceManager.OBSERVE_I18N_ARCHIVE);
    
    138
    -//                File archive = new File(directory.getParent().toFile(), ObserveResourceManager.OBSERVE_I18N_ARCHIVE.substring(1));
    
    139
    -//                try {
    
    140
    -//                    resourceManager.copyResource(resource, archive, "Copy i18n archive");
    
    141
    -//                    ZipUtil.uncompressFiltred(archive, directory.getParent().toFile());
    
    142
    -//                } finally {
    
    143
    -//                    if (Files.exists(archive.toPath())) {
    
    144
    -//                        try {
    
    145
    -//                            Files.delete(archive.toPath());
    
    146
    -//                        } catch (IOException e) {
    
    147
    -//                            log.error(String.format("Could not delete i18n archive %s", archive));
    
    148
    -//                        }
    
    149
    -//                    }
    
    150
    -//                }
    
    151
    -//
    
    152
    -//            }
    
    153
    -        };
    
    129
    +        if (config.getBuildVersion().isSnapshot() && Files.exists(i18nDirectory)) {
    
    130
    +            // always regenerate i18n
    
    131
    +            try {
    
    132
    +                Files.walk(i18nDirectory)
    
    133
    +                        .sorted(Comparator.reverseOrder())
    
    134
    +                        .map(Path::toFile)
    
    135
    +                        .forEach(File::delete);
    
    136
    +            } catch (IOException e) {
    
    137
    +                throw new IllegalStateException("Can't delete i18n directory: "+i18nDirectory, e);
    
    138
    +            }
    
    154 139
     
    
    140
    +        }
    
    141
    +        UserI18nBootLoader i18nInitializer = new UserI18nBootLoader(i18nDirectory, new DefaultI18nBootLoader(I18nConfiguration.createDefaultConfiguration()));
    
    155 142
             long t00 = System.nanoTime();
    
    156 143
     
    
    157 144
             Locale locale = config.getLocale();
    
    158 145
     
    
    159 146
             I18n.init(i18nInitializer, locale);
    
    160 147
     
    
    161
    -        if (log.isDebugEnabled()) {
    
    162 148
                 log.debug("i18n language : " + locale);
    
    163 149
                 log.debug("i18n loading time : " + StringUtil.convertTime(t00, System.nanoTime()));
    
    164
    -        }
    
    165 150
         }
    
    166 151
     
    
    167 152
         public abstract String getRunnerName();
    
    ... ... @@ -216,9 +201,7 @@ public abstract class ObserveRunner extends ApplicationRunner {
    216 201
         @Override
    
    217 202
         protected void onInit() throws Exception {
    
    218 203
     
    
    219
    -        if (log.isInfoEnabled()) {
    
    220
    -            log.info(t("observe.runner.init", new Date(), Arrays.toString(args)));
    
    221
    -        }
    
    204
    +        log.info(t("observe.runner.init", new Date(), Arrays.toString(args)));
    
    222 205
     
    
    223 206
             long t0 = System.nanoTime();
    
    224 207
     
    
    ... ... @@ -226,30 +209,22 @@ public abstract class ObserveRunner extends ApplicationRunner {
    226 209
     
    
    227 210
             ClientConfig config = initConfig();
    
    228 211
     
    
    229
    -        if (log.isInfoEnabled()) {
    
    230
    -            log.info(t("observe.runner.config.loaded", config.getVersion()));
    
    231
    -        }
    
    212
    +        log.info(t("observe.runner.config.loaded", config.getVersion()));
    
    232 213
     
    
    233 214
             // 2 - preparation des répertoires utilisateurs
    
    234 215
     
    
    235 216
             initUserDirectories(config);
    
    236 217
     
    
    237 218
             // 3 - Chargement de la configuration des logs utilisateur
    
    238
    -        if (!config.isDevMode()) {
    
    239
    -            initLog(config);
    
    240
    -        }
    
    219
    +        initLog(config);
    
    241 220
     
    
    242
    -        if (log.isInfoEnabled()) {
    
    243
    -            log.info(t("observe.runner.user.directories.loaded", config.getDataDirectory()));
    
    244
    -        }
    
    221
    +        log.info(t("observe.runner.user.directories.loaded", config.getDataDirectory()));
    
    245 222
     
    
    246 223
             // 3 - preparation i18n
    
    247 224
     
    
    248 225
             initI18n(config);
    
    249 226
     
    
    250
    -        if (log.isInfoEnabled()) {
    
    251
    -            log.info(t("observe.runner.i18n.loaded", config.getLocale().getDisplayLanguage()));
    
    252
    -        }
    
    227
    +        log.info(t("observe.runner.i18n.loaded", config.getLocale().getDisplayLanguage()));
    
    253 228
     
    
    254 229
             // 4 - preparation de la configuration des ui
    
    255 230
     
    
    ... ... @@ -265,9 +240,7 @@ public abstract class ObserveRunner extends ApplicationRunner {
    265 240
     
    
    266 241
             String time = StringUtil.convertTime(t0, System.nanoTime());
    
    267 242
     
    
    268
    -        if (log.isInfoEnabled()) {
    
    269
    -            log.info(t("observe.runner.context.loaded", time));
    
    270
    -        }
    
    243
    +        log.info(t("observe.runner.context.loaded", time));
    
    271 244
         }
    
    272 245
     
    
    273 246
         private void initLog(ClientConfig config) throws IOException {
    
    ... ... @@ -285,9 +258,7 @@ public abstract class ObserveRunner extends ApplicationRunner {
    285 258
         @Override
    
    286 259
         protected void onStart() throws Exception {
    
    287 260
     
    
    288
    -        if (log.isInfoEnabled()) {
    
    289
    -            log.info(t("observe.runner.start", new Date(), Arrays.toString(args)));
    
    290
    -        }
    
    261
    +        log.info(t("observe.runner.start", new Date(), Arrays.toString(args)));
    
    291 262
     
    
    292 263
             ObserveSwingApplicationContext context = ObserveSwingApplicationContext.get();
    
    293 264
     
    
    ... ... @@ -302,9 +273,7 @@ public abstract class ObserveRunner extends ApplicationRunner {
    302 273
             config.get().doAction(ClientConfig.Step.AfterInit.ordinal());
    
    303 274
     
    
    304 275
             if (!config.isDisplayMainUI()) {
    
    305
    -            if (log.isInfoEnabled()) {
    
    306
    -                log.info(t("observe.runner.quit.withno.ui"));
    
    307
    -            }
    
    276
    +            log.info(t("observe.runner.quit.withno.ui"));
    
    308 277
     
    
    309 278
                 unlock();
    
    310 279
                 return;
    
    ... ... @@ -318,9 +287,7 @@ public abstract class ObserveRunner extends ApplicationRunner {
    318 287
     
    
    319 288
             ObserveMainUI ui = startUI(context, config);
    
    320 289
     
    
    321
    -        if (log.isInfoEnabled()) {
    
    322
    -            log.info(t("observe.runner.ui.loaded"));
    
    323
    -        }
    
    290
    +        log.info(t("observe.runner.ui.loaded"));
    
    324 291
     
    
    325 292
             Boolean h2ServerMode = ObserveSwingApplicationContext.Entries.H2_SERVER_MODE.get();
    
    326 293
     
    
    ... ... @@ -355,18 +322,14 @@ public abstract class ObserveRunner extends ApplicationRunner {
    355 322
         protected void onClose(boolean reload) {
    
    356 323
             if (ObserveSwingApplicationContext.isInit()) {
    
    357 324
     
    
    358
    -            if (log.isDebugEnabled()) {
    
    359
    -                log.debug("Will close context...");
    
    360
    -            }
    
    325
    +            log.debug("Will close context...");
    
    361 326
                 ObserveSwingApplicationContext.get().close();
    
    362 327
             }
    
    363 328
         }
    
    364 329
     
    
    365 330
         @Override
    
    366 331
         protected void onShutdown() {
    
    367
    -        if (log.isInfoEnabled()) {
    
    368
    -            log.info("ObServe shutdown at " + new Date());
    
    369
    -        }
    
    332
    +        log.info("ObServe shutdown at " + new Date());
    
    370 333
     
    
    371 334
             try {
    
    372 335
     
    
    ... ... @@ -390,9 +353,7 @@ public abstract class ObserveRunner extends ApplicationRunner {
    390 353
     
    
    391 354
         @Override
    
    392 355
         protected void onShutdown(Exception ex) {
    
    393
    -        if (log.isErrorEnabled()) {
    
    394
    -            log.error("error while closing " + ex.getMessage(), ex);
    
    395
    -        }
    
    356
    +        log.error("error while closing " + ex.getMessage(), ex);
    
    396 357
             Runtime.getRuntime().halt(1);
    
    397 358
         }
    
    398 359
     
    
    ... ... @@ -422,9 +383,7 @@ public abstract class ObserveRunner extends ApplicationRunner {
    422 383
     
    
    423 384
             File dataDirectory = resourceManager.createDirectory(config, DATA_DIRECTORY);
    
    424 385
     
    
    425
    -        if (log.isDebugEnabled()) {
    
    426
    -            log.debug("user data directory : " + dataDirectory);
    
    427
    -        }
    
    386
    +        log.debug("user data directory : " + dataDirectory);
    
    428 387
     
    
    429 388
             resourceManager.createParentDirectory(config, DB_DIRECTORY, INITIAL_DB_DUMP);
    
    430 389
     
    
    ... ... @@ -443,9 +402,7 @@ public abstract class ObserveRunner extends ApplicationRunner {
    443 402
     
    
    444 403
             File resourcesDirectory = resourceManager.createDirectory(config, RESOURCES_DIRECTORY);
    
    445 404
     
    
    446
    -        if (log.isDebugEnabled()) {
    
    447
    -            log.debug("user resource data directory : " + resourcesDirectory);
    
    448
    -        }
    
    405
    +        log.debug("user resource data directory : " + resourcesDirectory);
    
    449 406
     
    
    450 407
             // 5 - application ui
    
    451 408
     
    
    ... ... @@ -502,18 +459,14 @@ public abstract class ObserveRunner extends ApplicationRunner {
    502 459
             boolean hasLocalStorage = new File(config.getLocalDBDirectory(), ClientConfig.DB_NAME).exists();
    
    503 460
             config.setLocalStorageExist(hasLocalStorage);
    
    504 461
             if (!hasLocalStorage) {
    
    505
    -            if (log.isInfoEnabled()) {
    
    506
    -                log.info(t("observe.init.no.local.db.detected", config.getLocalDBDirectory()));
    
    507
    -            }
    
    462
    +            log.info(t("observe.init.no.local.db.detected", config.getLocalDBDirectory()));
    
    508 463
             }
    
    509 464
     
    
    510 465
             boolean hasInitialDb = config.getInitialDbDump().exists();
    
    511 466
             config.setInitialDumpExist(hasInitialDb);
    
    512 467
     
    
    513 468
             if (!hasInitialDb) {
    
    514
    -            if (log.isInfoEnabled()) {
    
    515
    -                log.info(t("observe.init.no.initial.dump.detected", config.getInitialDbDump()));
    
    516
    -            }
    
    469
    +            log.info(t("observe.init.no.initial.dump.detected", config.getInitialDbDump()));
    
    517 470
             }
    
    518 471
         }
    
    519 472
     
    
    ... ... @@ -524,13 +477,9 @@ public abstract class ObserveRunner extends ApplicationRunner {
    524 477
                 UIHelper.initNimbusLoookAndFeel();
    
    525 478
             } catch (Exception e) {
    
    526 479
                 // could not find nimbus look-and-feel
    
    527
    -            if (log.isWarnEnabled()) {
    
    528
    -                log.warn(t("observe.warning.nimbus.landf"));
    
    529
    -            }
    
    480
    +            log.warn(t("observe.warning.nimbus.landf"));
    
    530 481
             } catch (Throwable e) {
    
    531
    -            if (log.isWarnEnabled()) {
    
    532
    -                log.warn(t("observe.warning.no.ui"));
    
    533
    -            }
    
    482
    +            log.warn(t("observe.warning.no.ui"));
    
    534 483
                 // pas d'environnement d'ui
    
    535 484
                 config.setCanUseUI(false);
    
    536 485
             }
    
    ... ... @@ -560,9 +509,7 @@ public abstract class ObserveRunner extends ApplicationRunner {
    560 509
                 }
    
    561 510
             }
    
    562 511
     
    
    563
    -        if (log.isInfoEnabled()) {
    
    564
    -            log.info(t("observe.runner.loading.ui.configuration", file));
    
    565
    -        }
    
    512
    +        log.info(t("observe.runner.loading.ui.configuration", file));
    
    566 513
             try {
    
    567 514
                 Properties p = resourceManager.getResource(file);
    
    568 515
                 UIHelper.loadUIConfig(p);
    

  • client-core/src/main/java/fr/ird/observe/client/ui/ObserveCommon.jcss
    ... ... @@ -149,6 +149,7 @@ BeanComboBox {
    149 149
     
    
    150 150
     BeanFilterableComboBox {
    
    151 151
       showReset:true;
    
    152
    +  tabToSelect:false;
    
    152 153
     }
    
    153 154
     
    
    154 155
     NormalTextEditor {
    

  • client-core/src/main/java/fr/ird/observe/client/ui/admin/AdminTabUIHandler.java
    ... ... @@ -55,6 +55,7 @@ import org.nuiton.jaxx.runtime.swing.wizard.ext.WizardState;
    55 55
     import org.nuiton.util.StringUtil;
    
    56 56
     
    
    57 57
     import javax.swing.JOptionPane;
    
    58
    +import javax.swing.JTextArea;
    
    58 59
     import java.io.PrintWriter;
    
    59 60
     import java.io.StringWriter;
    
    60 61
     import java.util.Collection;
    
    ... ... @@ -193,7 +194,9 @@ public class AdminTabUIHandler<U extends AdminTabUI> {
    193 194
         }
    
    194 195
     
    
    195 196
         public void addMessage(AdminStep step, String text) {
    
    196
    -        ui.getProgression().append(text + "\n");
    
    197
    +        JTextArea progression = ui.getProgression();
    
    198
    +        progression.append(text + "\n");
    
    199
    +        progression.setCaretPosition(progression.getDocument().getLength());
    
    197 200
         }
    
    198 201
     
    
    199 202
         protected void logExportResult(String i18nKey,