@SuppressWarnings("unchecked")
  protected void loadConfiguration() {
    String configFileName = getConfigurationFileName();
    boolean debugGlobalConfiguration =
        Boolean.parseBoolean(defaultValues.get(G_PROPERTIES.DEBUG_GLOBALCONFIGURATION));

    XMLDecoder decoder = null;
    if (configFileName != null && new File(configFileName).canRead())
      try {
        if (debugGlobalConfiguration)
          System.out.println("Loaded configuration file " + configFileName);
        decoder = new XMLDecoder(new FileInputStream(configFileName));
        properties = (Properties) decoder.readObject();
        windowCoords = (HashMap<Integer, WindowPosition>) decoder.readObject();
        decoder.close();
      } catch (Exception e) { // failed loading, (almost) ignore this.
        System.err.println("Failed to load " + configFileName);
        e.printStackTrace();
        if (debugGlobalConfiguration) {
          System.err.println("Failed to load " + configFileName);
          e.printStackTrace();
        }
      } finally {
        if (decoder != null) decoder.close();
      }
    if (windowCoords == null) windowCoords = new HashMap<Integer, WindowPosition>();
    if (properties == null) properties = new Properties();
    boolean valuesSet = false, firstValue = true;
    for (G_PROPERTIES prop : G_PROPERTIES.values()) {
      String name = prop.name(), value = null;
      try {
        value = System.getProperty(name);
      } catch (Exception ex) {
      } // ignore exception if cannot extract a value
      if (value != null) { // new value set via command-line
        if (debugGlobalConfiguration) {
          if (firstValue) firstValue = false;
          else System.out.print(',');
          System.out.print(name + "=" + value);
        }
        properties.setProperty(name, value);
        valuesSet = true;
      }
    }
    if (valuesSet && debugGlobalConfiguration) System.out.println();
  }
  public void setProperty(G_PROPERTIES key, String string) {
    if (properties == null) {
      properties = new Properties();
    }
    if (properties == null) loadConfiguration();

    properties.setProperty(key.name(), string);
  }
 /**
  * Retrieves the name of the property from the property file. The first call to this method opens
  * the property file.
  *
  * @param name the name of the property.
  * @param defaultValue the default value of the property
  * @return property value, default value if not found
  */
 public String getProperty(G_PROPERTIES name) {
   if (properties == null) loadConfiguration();
   return properties.getProperty(name.name(), defaultValues.get(name));
 }