OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 156 Rev 177
Line 68... Line 68...
68
import java.util.Date;
68
import java.util.Date;
69
import java.util.HashSet;
69
import java.util.HashSet;
70
import java.util.List;
70
import java.util.List;
71
import java.util.ListIterator;
71
import java.util.ListIterator;
72
import java.util.Locale;
72
import java.util.Locale;
-
 
73
import java.util.Objects;
73
import java.util.Properties;
74
import java.util.Properties;
74
import java.util.ResourceBundle.Control;
75
import java.util.ResourceBundle.Control;
75
import java.util.Set;
76
import java.util.Set;
76
import java.util.concurrent.Callable;
77
import java.util.concurrent.Callable;
77
import java.util.concurrent.ExecutionException;
78
import java.util.concurrent.ExecutionException;
Line 207... Line 208...
207
    private File wd;
208
    private File wd;
208
    @GuardedBy("restLock")
209
    @GuardedBy("restLock")
209
    private BaseDirs baseDirs;
210
    private BaseDirs baseDirs;
210
    @GuardedBy("restLock")
211
    @GuardedBy("restLock")
211
    private File logDir;
212
    private File logDir;
-
 
213
    @GuardedBy("restLock")
-
 
214
    private Locale locale = Locale.getDefault();
212
    private final boolean inIDE;
215
    private final boolean inIDE;
213
 
216
 
214
    // split sql tree and the rest since creating the tree is costly
217
    // split sql tree and the rest since creating the tree is costly
215
    // and nodes are inter-dependant, while the rest is mostly fast
218
    // and nodes are inter-dependant, while the rest is mostly fast
216
    // different instances, otherwise lock every Conf instances
219
    // different instances, otherwise lock every Conf instances
Line 996... Line 999...
996
        // perhaps listen to UserProps (as in TM)
999
        // perhaps listen to UserProps (as in TM)
997
        return loadTranslations(trns, this.getRoot(), mappings);
1000
        return loadTranslations(trns, this.getRoot(), mappings);
998
    }
1001
    }
999
 
1002
 
1000
    protected final SQLFieldTranslator loadTranslations(final SQLFieldTranslator trns, final DBRoot root, final List<String> mappings) {
1003
    protected final SQLFieldTranslator loadTranslations(final SQLFieldTranslator trns, final DBRoot root, final List<String> mappings) {
1001
        final Locale locale = TM.getInstance().getTranslationsLocale();
1004
        final Locale locale = this.getLocale();
1002
        final Control cntrl = TranslationManager.getControl();
1005
        final Control cntrl = TranslationManager.getControl();
1003
        boolean found = false;
1006
        boolean found = false;
1004
        // better to have a translation in the correct language than a translation for the correct
1007
        // better to have a translation in the correct language than a translation for the correct
1005
        // customer in the wrong language
1008
        // customer in the wrong language
1006
        final String fakeBaseName = "";
1009
        final String fakeBaseName = "";
Line 1371... Line 1374...
1371
                this.baseDirs = this.createBaseDirs();
1374
                this.baseDirs = this.createBaseDirs();
1372
            return this.baseDirs;
1375
            return this.baseDirs;
1373
        }
1376
        }
1374
    }
1377
    }
1375
 
1378
 
-
 
1379
    @Override
-
 
1380
    public Locale getLocale() {
-
 
1381
        synchronized (this.restLock) {
-
 
1382
            return this.locale;
-
 
1383
        }
-
 
1384
    }
-
 
1385
 
1376
    // *** setters
1386
    // *** setters
1377
 
1387
 
1378
    // MAYBE add synchronized (not necessary since they're private, and only called with the lock)
1388
    // MAYBE add synchronized (not necessary since they're private, and only called with the lock)
1379
 
1389
 
1380
    private final void setFilter(final SQLFilter filter) {
1390
    private final void setFilter(final SQLFilter filter) {
Line 1395... Line 1405...
1395
 
1405
 
1396
    private final void setWD(final File dir) {
1406
    private final void setWD(final File dir) {
1397
        this.wd = dir;
1407
        this.wd = dir;
1398
    }
1408
    }
1399
 
1409
 
-
 
1410
    public void setLocale(Locale locale) {
-
 
1411
        Objects.requireNonNull(locale);
-
 
1412
        // don't create the directory
-
 
1413
        final boolean localeChangedAndDirExists;
-
 
1414
        synchronized (this.restLock) {
-
 
1415
            if (locale.equals(this.locale)) {
-
 
1416
                localeChangedAndDirExists = false;
-
 
1417
            } else {
-
 
1418
                this.locale = locale;
-
 
1419
                localeChangedAndDirExists = this.directory.isComputeStarted();
-
 
1420
            }
-
 
1421
        }
-
 
1422
        if (localeChangedAndDirExists) {
-
 
1423
            final SQLElementDirectory dir = this.getDirectory();
-
 
1424
            dir.setTranslator(createTranslator(dir));
-
 
1425
        }
-
 
1426
    }
-
 
1427
 
1400
    public FieldMapper getFieldMapper() {
1428
    public FieldMapper getFieldMapper() {
1401
        return fieldMapper;
1429
        return fieldMapper;
1402
    }
1430
    }
1403
 
1431
 
1404
    public void setFieldMapper(FieldMapper fieldMapper) {
1432
    public void setFieldMapper(FieldMapper fieldMapper) {