Config.java :  » Test-Coverage » salome-tmf » org » objectweb » salome_tmf » api » Java Open Source

Java Open Source » Test Coverage » salome tmf 
salome tmf » org » objectweb » salome_tmf » api » Config.java
package org.objectweb.salome_tmf.api;

import java.util.Vector;

import org.objectweb.salome_tmf.api.sql.ISQLConfig;
import org.objectweb.salome_tmf.api.sql.ISQLObjectFactory;

public class Config {
  boolean DEBUG = true;
  boolean ALLOW_PLUGINS = true;
  boolean IDE_DEV = false;
  boolean NET_CHANGE_TRACK = true;
  Vector LOCALES_LIST = null;
  static String locale = null;
  boolean WITH_ICAL = false;
  boolean LOCK_ON_EXEC = true;
  int LOCK_METHODE = 0; //-1 = NONE, 0 = mysql, 1 = salome 
  boolean LOCK_EXECUTED_TEST = true;
  boolean DYNAMIC_VALUE_DATASET = true;
  
  static ISQLConfig pISQLConfig = null;
  void init(ISQLObjectFactory pISQLObjectFactory){
    if (pISQLConfig == null){
      pISQLConfig = pISQLObjectFactory.getISQLConfig();
    }
  }
  
  public boolean isALLOW_PLUGINS() {
    return ALLOW_PLUGINS;
  }
  void setALLOW_PLUGINS(boolean allow_plugins) {
    ALLOW_PLUGINS = allow_plugins;
  }
  
  public boolean isDEBUG() {
    return DEBUG;
  }
  void setDEBUG(boolean debug) {
    DEBUG = debug;
  }
  
  public boolean isIDE_DEV() {
    return IDE_DEV;
  }
  void setIDE_DEV(boolean ide_dev) {
    IDE_DEV = ide_dev;
  }
  
  void setLockOnExec(boolean db_lock) {
    LOCK_ON_EXEC = db_lock;
  }
  
  public boolean isLockOnExec() {
    return LOCK_ON_EXEC;
  }
  
  void setLockExecutedTest(boolean lock_test) {
    LOCK_EXECUTED_TEST = lock_test;
  }
  
  public boolean isLockExecutedTest() {
    return LOCK_EXECUTED_TEST;
  }
  
   void setUSE_DB_LOCK(int db_lock) {
     LOCK_METHODE = db_lock;
  }
  
  public int getUSE_DB_LOCK() {
    return (LOCK_METHODE);
  }
   
  public boolean isNET_CHANGE_TRACK() {
    return NET_CHANGE_TRACK;
  }
  void setNET_CHANGE_TRACK(boolean net_change_track) {
    NET_CHANGE_TRACK = net_change_track;
  }
  
  public boolean isWITH_ICAL() {
    return WITH_ICAL;
  }
  void setWITH_ICAL(boolean with_ical) {
    WITH_ICAL = with_ical;
  }
  
  public boolean isDYNAMIC_VALUE_DATASET(){
    return DYNAMIC_VALUE_DATASET;
  }
  
  void setDYNAMIC_VALUE_DATASET(boolean dynamic) {
    DYNAMIC_VALUE_DATASET = dynamic;
  }
  
  public static String getUsedLocale() {
    if (locale != null){
      return locale;
    } else {
      if (pISQLConfig != null){
        try {
          locale = pISQLConfig.getSalomeConf("Locale");
        } catch (Exception e){
          e.printStackTrace();
          Util.log("[Config->getUsedLocale]" + e);
        }
      } else {
        //Util.log("[Config->getUsedLocale] return default local en");
        return "en";
      }
    }
    return locale;
  }
  
  public void saveLocale(String newLocale) {
    if (pISQLConfig != null){
      try {
      locale = newLocale;
      pISQLConfig.updateSalomeConf("Locale", newLocale);
      } catch (Exception e){
        e.printStackTrace();
        Util.log("[Config->saveLocale]" + e);
      }
    }
  }
  
  public void addLocale(String local){
    if (pISQLConfig != null){
      try {
      String list = pISQLConfig.getSalomeConf("LocalesList");
      list = list + ", " +local;
      pISQLConfig.updateSalomeConf("LocalesList", list);
      } catch (Exception e){
        e.printStackTrace();
        Util.log("[Config->addLocale]" + e);
      }
    }
  }
  
  public Vector getLocales() {
    if (LOCALES_LIST != null){
      return LOCALES_LIST;
    } else {
      if (pISQLConfig != null){
        try {
          String list = pISQLConfig.getSalomeConf("LocalesList");
          String tabList[] = list.split(",");
          LOCALES_LIST = new Vector();
          for (int i = 0 ; i < tabList.length; i++){
            LOCALES_LIST.add(tabList[i]);
          }
          return LOCALES_LIST;
        } catch (Exception e){
          LOCALES_LIST = null;
          e.printStackTrace();
          Util.log("[Config->getLocales]" + e);
        }
      }
    }
    return null;
  }
  
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.