001: package org.objectweb.salome_tmf.api;
002:
003: import java.util.Vector;
004:
005: import org.objectweb.salome_tmf.api.sql.ISQLConfig;
006: import org.objectweb.salome_tmf.api.sql.ISQLObjectFactory;
007:
008: public class Config {
009: boolean DEBUG = true;
010: boolean ALLOW_PLUGINS = true;
011: boolean IDE_DEV = false;
012: boolean NET_CHANGE_TRACK = true;
013: Vector LOCALES_LIST = null;
014: static String locale = null;
015: boolean WITH_ICAL = false;
016: boolean LOCK_ON_EXEC = true;
017: int LOCK_METHODE = 0; //-1 = NONE, 0 = mysql, 1 = salome
018: boolean LOCK_EXECUTED_TEST = true;
019: boolean DYNAMIC_VALUE_DATASET = true;
020:
021: static ISQLConfig pISQLConfig = null;
022:
023: void init(ISQLObjectFactory pISQLObjectFactory) {
024: if (pISQLConfig == null) {
025: pISQLConfig = pISQLObjectFactory.getISQLConfig();
026: }
027: }
028:
029: public boolean isALLOW_PLUGINS() {
030: return ALLOW_PLUGINS;
031: }
032:
033: void setALLOW_PLUGINS(boolean allow_plugins) {
034: ALLOW_PLUGINS = allow_plugins;
035: }
036:
037: public boolean isDEBUG() {
038: return DEBUG;
039: }
040:
041: void setDEBUG(boolean debug) {
042: DEBUG = debug;
043: }
044:
045: public boolean isIDE_DEV() {
046: return IDE_DEV;
047: }
048:
049: void setIDE_DEV(boolean ide_dev) {
050: IDE_DEV = ide_dev;
051: }
052:
053: void setLockOnExec(boolean db_lock) {
054: LOCK_ON_EXEC = db_lock;
055: }
056:
057: public boolean isLockOnExec() {
058: return LOCK_ON_EXEC;
059: }
060:
061: void setLockExecutedTest(boolean lock_test) {
062: LOCK_EXECUTED_TEST = lock_test;
063: }
064:
065: public boolean isLockExecutedTest() {
066: return LOCK_EXECUTED_TEST;
067: }
068:
069: void setUSE_DB_LOCK(int db_lock) {
070: LOCK_METHODE = db_lock;
071: }
072:
073: public int getUSE_DB_LOCK() {
074: return (LOCK_METHODE);
075: }
076:
077: public boolean isNET_CHANGE_TRACK() {
078: return NET_CHANGE_TRACK;
079: }
080:
081: void setNET_CHANGE_TRACK(boolean net_change_track) {
082: NET_CHANGE_TRACK = net_change_track;
083: }
084:
085: public boolean isWITH_ICAL() {
086: return WITH_ICAL;
087: }
088:
089: void setWITH_ICAL(boolean with_ical) {
090: WITH_ICAL = with_ical;
091: }
092:
093: public boolean isDYNAMIC_VALUE_DATASET() {
094: return DYNAMIC_VALUE_DATASET;
095: }
096:
097: void setDYNAMIC_VALUE_DATASET(boolean dynamic) {
098: DYNAMIC_VALUE_DATASET = dynamic;
099: }
100:
101: public static String getUsedLocale() {
102: if (locale != null) {
103: return locale;
104: } else {
105: if (pISQLConfig != null) {
106: try {
107: locale = pISQLConfig.getSalomeConf("Locale");
108: } catch (Exception e) {
109: e.printStackTrace();
110: Util.log("[Config->getUsedLocale]" + e);
111: }
112: } else {
113: //Util.log("[Config->getUsedLocale] return default local en");
114: return "en";
115: }
116: }
117: return locale;
118: }
119:
120: public void saveLocale(String newLocale) {
121: if (pISQLConfig != null) {
122: try {
123: locale = newLocale;
124: pISQLConfig.updateSalomeConf("Locale", newLocale);
125: } catch (Exception e) {
126: e.printStackTrace();
127: Util.log("[Config->saveLocale]" + e);
128: }
129: }
130: }
131:
132: public void addLocale(String local) {
133: if (pISQLConfig != null) {
134: try {
135: String list = pISQLConfig.getSalomeConf("LocalesList");
136: list = list + ", " + local;
137: pISQLConfig.updateSalomeConf("LocalesList", list);
138: } catch (Exception e) {
139: e.printStackTrace();
140: Util.log("[Config->addLocale]" + e);
141: }
142: }
143: }
144:
145: public Vector getLocales() {
146: if (LOCALES_LIST != null) {
147: return LOCALES_LIST;
148: } else {
149: if (pISQLConfig != null) {
150: try {
151: String list = pISQLConfig
152: .getSalomeConf("LocalesList");
153: String tabList[] = list.split(",");
154: LOCALES_LIST = new Vector();
155: for (int i = 0; i < tabList.length; i++) {
156: LOCALES_LIST.add(tabList[i]);
157: }
158: return LOCALES_LIST;
159: } catch (Exception e) {
160: LOCALES_LIST = null;
161: e.printStackTrace();
162: Util.log("[Config->getLocales]" + e);
163: }
164: }
165: }
166: return null;
167: }
168:
169: }
|