[jsword-svn] common/java/config/org/crosswire/common/config s

jswordcvs at crosswire.org jswordcvs at crosswire.org
Wed Oct 6 15:52:36 MST 2004


Update of /cvs/jsword/common/java/config/org/crosswire/common/config
In directory www.crosswire.org:/tmp/cvs-serv27031/java/config/org/crosswire/common/config

Modified Files:
	Msg.properties Msg.java Config.java 
Added Files:
	ConfigException.java 
Log Message:
[BD-2] and linked issues

Index: Msg.properties
===================================================================
RCS file: /cvs/jsword/common/java/config/org/crosswire/common/config/Msg.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Msg.properties	14 Jun 2004 05:27:31 -0000	1.1
--- Msg.properties	6 Oct 2004 22:52:34 -0000	1.2
***************
*** 14,15 ****
--- 14,16 ----
  StringOptionsChoice.ConfigNoMap=Missing <map> element.
  IntOptionsChoice.Ignore=Ignoring invalid option: {0}
+ Config.SetFail=Failed to set option: {0}

Index: Config.java
===================================================================
RCS file: /cvs/jsword/common/java/config/org/crosswire/common/config/Config.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Config.java	16 Aug 2004 22:07:35 -0000	1.5
--- Config.java	6 Oct 2004 22:52:34 -0000	1.6
***************
*** 73,77 ****
  {
      /**
!      * Ensure that we can not be instansiated
       * @param title The name for dialog boxes and properties files
       */
--- 73,77 ----
  {
      /**
!      * Config ctor
       * @param title The name for dialog boxes and properties files
       */
***************
*** 265,269 ****
      public void localToApplication(boolean force)
      {
!         int highest_change = Choice.PRIORITY_LOWEST;
  
          if (force)
--- 265,269 ----
      public void localToApplication(boolean force)
      {
!         int highestChange = Choice.PRIORITY_LOWEST;
  
          if (force)
***************
*** 280,296 ****
              {
                  String key = (String) it.next();
!                 Choice model = getChoice(key);
  
!                 if (model.getPriority() == priority)
                  {
!                     String old_value = model.getString();
!                     String new_value = local.getProperty(key);
  
                      // The new value shouldn't really be blank - obviously this
                      // choice has just been added, substitute the default.
!                     if (new_value == null)
                      {
!                         local.put(key, old_value);
!                         new_value = old_value;
                      }
  
--- 280,296 ----
              {
                  String key = (String) it.next();
!                 Choice choice = getChoice(key);
  
!                 if (choice.getPriority() == priority)
                  {
!                     String oldValue = choice.getString();
!                     String newValue = local.getProperty(key);
  
                      // The new value shouldn't really be blank - obviously this
                      // choice has just been added, substitute the default.
!                     if (newValue == null)
                      {
!                         local.put(key, oldValue);
!                         newValue = oldValue;
                      }
  
***************
*** 301,317 ****
                          // changed.
                          if (force
!                             || priority < highest_change
!                             || !new_value.equals(old_value))
                          {
!                             log.info("Setting " + key + "=" + new_value + " (was " + old_value + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
!                             model.setString(new_value);
  
!                             if (priority > highest_change)
                              {
!                                 highest_change = priority;
  
                                  if (!force)
                                  {
!                                     log.info("Change at level " + highest_change + ", all changes will propogate regardless"); //$NON-NLS-1$ //$NON-NLS-2$
                                  }
                              }
--- 301,317 ----
                          // changed.
                          if (force
!                             || priority < highestChange
!                             || !newValue.equals(oldValue))
                          {
!                             log.info("Setting " + key + "=" + newValue + " (was " + oldValue + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
!                             choice.setString(newValue);
  
!                             if (priority > highestChange)
                              {
!                                 highestChange = priority;
  
                                  if (!force)
                                  {
!                                     log.info("Change at level " + highestChange + ", all changes will propogate regardless"); //$NON-NLS-1$ //$NON-NLS-2$
                                  }
                              }
***************
*** 320,325 ****
                      catch (Exception ex)
                      {
!                         log.warn("Failure with " + key + "=" + new_value, ex);  //$NON-NLS-1$ //$NON-NLS-2$
!                         Reporter.informUser(this, ex);
                      }
                  }
--- 320,325 ----
                      catch (Exception ex)
                      {
!                         log.warn("Failure setting " + key + "=" + newValue, ex);  //$NON-NLS-1$ //$NON-NLS-2$
!                         Reporter.informUser(this, new ConfigException(Msg.CONFIG_SETFAIL, ex, new Object[] { choice.getFullPath() } ));
                      }
                  }
***************
*** 413,423 ****
      public static String getPath(String key)
      {
!         int last_dot = key.lastIndexOf('.');
!         if (last_dot == -1)
          {
              throw new IllegalArgumentException("key=" + key + " does not contain a dot."); //$NON-NLS-1$ //$NON-NLS-2$
          }
  
!         return key.substring(0, last_dot);
      }
  
--- 413,423 ----
      public static String getPath(String key)
      {
!         int lastDot = key.lastIndexOf('.');
!         if (lastDot == -1)
          {
              throw new IllegalArgumentException("key=" + key + " does not contain a dot."); //$NON-NLS-1$ //$NON-NLS-2$
          }
  
!         return key.substring(0, lastDot);
      }
  
***************
*** 427,437 ****
      public static String getLeaf(String key)
      {
!         int last_dot = key.lastIndexOf('.');
!         if (last_dot == -1)
          {
              throw new IllegalArgumentException("key=" + key + " does not contain a dot."); //$NON-NLS-1$ //$NON-NLS-2$
          }
  
!         return key.substring(last_dot + 1);
      }
  
--- 427,437 ----
      public static String getLeaf(String key)
      {
!         int lastDot = key.lastIndexOf('.');
!         if (lastDot == -1)
          {
              throw new IllegalArgumentException("key=" + key + " does not contain a dot."); //$NON-NLS-1$ //$NON-NLS-2$
          }
  
!         return key.substring(lastDot + 1);
      }
  
***************
*** 442,446 ****
      public void addConfigListener(ConfigListener li)
      {
!         listener_list.add(ConfigListener.class, li);
      }
  
--- 442,446 ----
      public void addConfigListener(ConfigListener li)
      {
!         listenerList.add(ConfigListener.class, li);
      }
  
***************
*** 451,455 ****
      public void removeConfigListener(ConfigListener li)
      {
!         listener_list.remove(ConfigListener.class, li);
      }
  
--- 451,455 ----
      public void removeConfigListener(ConfigListener li)
      {
!         listenerList.remove(ConfigListener.class, li);
      }
  
***************
*** 460,464 ****
      {
          // Guaranteed to return a non-null array
!         Object[] listeners = listener_list.getListenerList();
  
          // Process the listeners last to first, notifying
--- 460,464 ----
      {
          // Guaranteed to return a non-null array
!         Object[] listeners = listenerList.getListenerList();
  
          // Process the listeners last to first, notifying
***************
*** 485,489 ****
      {
          // Guaranteed to return a non-null array
!         Object[] listeners = listener_list.getListenerList();
  
          // Process the listeners last to first, notifying
--- 485,489 ----
      {
          // Guaranteed to return a non-null array
!         Object[] listeners = listenerList.getListenerList();
  
          // Process the listeners last to first, notifying
***************
*** 532,535 ****
       * The list of listeners
       */
!     protected EventListenerList listener_list = new EventListenerList();
  }
--- 532,535 ----
       * The list of listeners
       */
!     protected EventListenerList listenerList = new EventListenerList();
  }

--- NEW FILE: ConfigException.java ---
package org.crosswire.common.config;

import org.crosswire.common.util.LucidException;
import org.crosswire.common.util.MsgBase;

/**
 * Something went wrong while setting config options.
 * 
 * <p><table border='1' cellPadding='3' cellSpacing='0'>
 * <tr><td bgColor='white' class='TableRowColor'><font size='-7'>
 *
 * Distribution Licence:<br />
 * JSword is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General Public License,
 * version 2 as published by the Free Software Foundation.<br />
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.<br />
 * The License is available on the internet
 * <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, or by writing to:
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 * MA 02111-1307, USA<br />
 * The copyright to this program is held by it's authors.
 * </font></td></tr></table>
 * @see gnu.gpl.Licence
 * @author Joe Walker [joe at eireneh dot com]
 * @version $Id: ConfigException.java,v 1.1 2004/10/06 22:52:34 joe Exp $
 */
public class ConfigException extends LucidException
{
    /**
     * Construct the Exception with a message
     * @param msg The resource id to read
     */
    public ConfigException(MsgBase msg)
    {
        super(msg);
    }

    /**
     * Construct the Exception with a message and a nested Exception
     * @param msg The resource id to read
     * @param ex The nested Exception
     */
    public ConfigException(MsgBase msg, Throwable ex)
    {
        super(msg, ex);
    }

    /**
     * Construct the Exception with a message and some Msg params
     * @param msg The resource id to read
     * @param params An array of parameters
     */
    public ConfigException(MsgBase msg, Object[] params)
    {
        super(msg, params);
    }

    /**
     * Construct the Exception with a message, a nested Exception and some Msg params
     * @param msg The resource id to read
     * @param ex The nested Exception
     * @param params An array of parameters
     */
    public ConfigException(MsgBase msg, Throwable ex, Object[] params)
    {
        super(msg, ex, params);
    }
}

Index: Msg.java
===================================================================
RCS file: /cvs/jsword/common/java/config/org/crosswire/common/config/Msg.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Msg.java	28 Apr 2004 22:35:38 -0000	1.1
--- Msg.java	6 Oct 2004 22:52:34 -0000	1.2
***************
*** 37,40 ****
--- 37,41 ----
      static final Msg NO_HELP = new Msg("AbstractReflectedChoice.NoHelp"); //$NON-NLS-1$
      static final Msg IGNORE = new Msg("IntOptionsChoice.Ignore"); //$NON-NLS-1$
+     static final Msg CONFIG_SETFAIL = new Msg("Config.SetFail"); //$NON-NLS-1$
  
      /**



More information about the jsword-svn mailing list