Esempio n. 1
0
 /**
  * A color is a set of 3 values separated by spaces
  *
  * @param property the property key associated to the color
  * @param defaultValue the color to return if the property key is not associated to a color
  * @return the color associated to the property key, or <code>defaultValue</code> if there is no
  *     color associated to the property
  */
 public Color getColor(String property, Color defaultValue) {
   // TODO enhance error handling
   Color color = defaultValue;
   String colorValue = getProperty(property);
   if (colorValue == null) {
     displayError("Property " + property + " not found"); // $NON-NLS-1$ //$NON-NLS-2$
   } else {
     color = null;
     try {
       color = TColor.translateColor(colorValue, null);
     } catch (Exception e) {
     }
     if (color == null) {
       try {
         StringTokenizer tokenizer = new StringTokenizer(colorValue);
         int red = Integer.parseInt(tokenizer.nextToken());
         int green = Integer.parseInt(tokenizer.nextToken());
         int blue = Integer.parseInt(tokenizer.nextToken());
         color = new Color(red, green, blue);
       } catch (Exception ex) {
         displayError("Failed loading color " + property); // $NON-NLS-1$
       }
     }
   }
   return color;
 }
Esempio n. 2
0
  /**
   * Loads the package information from configuration file and builds the list of the package to
   * load by default
   *
   * @param props the property set containing the package information
   */
  private void loadPackageInfo(Properties props) throws ConfigurationException {
    importPackageCmd = loadProperty(props, IMPORT_PKG_CMD_P);
    addClassPathCmd = loadProperty(props, ADD_CLASSPATH_CMD_P);
    parameterTag = loadProperty(props, PARAMETER_TAG_P);

    List<String> pkgList = new ArrayList<String>();
    for (StringTokenizer pkgTokenizer = new StringTokenizer(IMPORT_PKG_LST, IMPORT_PKG_LST_SEP);
        pkgTokenizer.hasMoreTokens(); ) {
      String packageName = pkgTokenizer.nextToken();
      pkgList.add(packageName);
    }
    if (defaultLanguage) pkgList.add("org.colombbus.tangara.en.*");
    else pkgList.add("org.colombbus.tangara." + getLanguage() + ".*");
    scriptImportPkgList = pkgList.toArray(scriptImportPkgList);
  }
Esempio n. 3
0
  /**
   * Loads the declarations of the script engines declared in a property set
   *
   * @param props property set containing the configuration
   * @throws ConfigurationException if the scripting languages cannot be loaded
   */
  private void loadScriptingLanguages(Properties props) throws ConfigurationException {
    String strEngineList = loadProperty(props, SCRIPT_ENGINE_LIST_P);

    for (StringTokenizer engineTokenizer = new StringTokenizer(strEngineList);
        engineTokenizer.hasMoreTokens(); ) {
      String engineBaseItem = engineTokenizer.nextToken();
      String engineName = props.getProperty(engineBaseItem + ".name"); // $NON-NLS-1$
      String engineClass = props.getProperty(engineBaseItem + ".class"); // $NON-NLS-1$
      String engineExtProps = props.getProperty(engineBaseItem + ".extensions"); // $NON-NLS-1$
      String[] extArray = null;
      if (engineExtProps != null) {
        List<String> extList = new ArrayList<String>();
        for (StringTokenizer extTokenizer = new StringTokenizer(engineExtProps);
            extTokenizer.hasMoreTokens(); ) {
          String extension = extTokenizer.nextToken();
          ext = extension;
          extList.add(extension);
        }
        extArray = extList.toArray(new String[0]);
      }
      BSFManager.registerScriptingEngine(engineName, engineClass, extArray);
      System.out.println("Script " + engineName + " loaded"); // $NON-NLS-1$ //$NON-NLS-2$
    }

    defaultEngineName = loadProperty(props, DFLT_SCRIPT_ENGINE_P);
  }