cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw/help HelpManager.java

2003-12-23 Thread psmith
psmith  2003/12/23 13:43:30

  Modified:src/java/org/apache/log4j/chainsaw/help HelpManager.java
  Log:
  Jalopied, and refactored a new method to assist other
  classes.
  
  Revision  ChangesPath
  1.4   +155 -137  
jakarta-log4j/src/java/org/apache/log4j/chainsaw/help/HelpManager.java
  
  Index: HelpManager.java
  ===
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/help/HelpManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HelpManager.java  23 Dec 2003 02:54:40 -  1.3
  +++ HelpManager.java  23 Dec 2003 21:43:30 -  1.4
  @@ -49,13 +49,14 @@
   
   package org.apache.log4j.chainsaw.help;
   
  +import org.apache.log4j.chainsaw.ChainsawConstants;
  +import org.apache.log4j.helpers.LogLog;
  +
   import java.beans.PropertyChangeEvent;
   import java.beans.PropertyChangeListener;
   import java.beans.PropertyChangeSupport;
  -import java.net.URL;
   
  -import org.apache.log4j.chainsaw.ChainsawConstants;
  -import org.apache.log4j.helpers.LogLog;
  +import java.net.URL;
   
   
   /**
  @@ -69,144 +70,161 @@
*
*/
   public final class HelpManager {
  -  private static final HelpManager instance = new HelpManager();
  -  private HelpLocator helpLocator = new HelpLocator();
  -  private URL helpURL;
  -  private final PropertyChangeSupport propertySupport =
  -new PropertyChangeSupport(this);
   
  -  private HelpManager() {
  -
  +private static final HelpManager instance = new HelpManager();
  +private HelpLocator helpLocator = new HelpLocator();
  +private URL helpURL;
  +private final PropertyChangeSupport propertySupport =
  +new PropertyChangeSupport(this);
  +
  +private HelpManager() {
  +
   //TODO setup all the base URLs in the default.properties and configure in 
ApplicationPreferenceModel
  -
  -try {
  -  if (System.getProperty("log4j.chainsaw.localDocs")!=null) {
  -LogLog.info("Adding HelpLocator for localDocs property=" 
+System.getProperty("log4j.chainsaw.localDocs") );
  -helpLocator.installLocator(new 
URL(System.getProperty("log4j.chainsaw.localDocs")));
  -  }
  -} catch (Exception e) {
  -  // TODO: handle exception
  -}
  +
  +try {
  +
  +if (System.getProperty("log4j.chainsaw.localDocs") != null) {
  +LogLog.info("Adding HelpLocator for localDocs property=" +
  +System.getProperty("log4j.chainsaw.localDocs"));
  +helpLocator.installLocator(new URL(
  +System.getProperty("log4j.chainsaw.localDocs")));
  +}
  +} catch (Exception e) {
  +// TODO: handle exception
  +}
  +
   helpLocator.installClassloaderLocator(this.getClass().getClassLoader());
   //  helpLocator.installLocator(new URL());
  -  }
  +}
  +
  +/**
  + * @return
  + */
  +public final URL getHelpURL() {
  +
  +return helpURL;
  +}
  +
  +/**
  + * The current Help URL that should be displayed, and is
  + * a PropertyChangeListener supported property.
  + *
  + * This method ALWAYS fires property change events
  + * even if the value is the same (the oldvalue
  + * of the event will be null)
  + * @param helpURL
  + */
  +public final void setHelpURL(URL helpURL) {
  +this.helpURL = helpURL;
  +firePropertyChange("helpURL", null, this.helpURL);
  +}
  +
  +/**
  + * @param listener
  + */
  +public void addPropertyChangeListener(PropertyChangeListener listener) {
  +propertySupport.addPropertyChangeListener(listener);
  +}
  +
  +/**
  + * @param propertyName
  + * @param listener
  + */
  +public synchronized void addPropertyChangeListener(String propertyName,
  +PropertyChangeListener listener) {
  +propertySupport.addPropertyChangeListener(propertyName, listener);
  +}
  +
  +/**
  + * @param evt
  + */
  +public void firePropertyChange(PropertyChangeEvent evt) {
  +propertySupport.firePropertyChange(evt);
  +}
  +
  +/**
  + * @param propertyName
  + * @param oldValue
  + * @param newValue
  + */
  +public void firePropertyChange(String propertyName, boolean oldValue,
  +boolean newValue) {
  +propertySupport.firePropertyChange(propertyName, oldValue, newValue);
  +}
  +
  +/**
  + * @param propertyName
  + * @param oldValue
  + * @param newValue
  + */
  +public void firePropertyChange(String propertyName, int oldValue,
  +int newValue) {
  +propertySupport.firePropertyChange(propertyName, oldValue, newValue);
  +}
  +
  +/**
  + * @param propertyName
  + * @param oldValue
  + * @param newValue
  + */
  +public void firePrope

cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw ChainsawConstants.java

2003-12-23 Thread psmith
psmith  2003/12/23 13:44:17

  Modified:src/java/org/apache/log4j/chainsaw ChainsawConstants.java
  Log:
  Added a new constant, the value of which will be changing
  once the real resource itself has been created.
  
  Revision  ChangesPath
  1.8   +3 -0  
jakarta-log4j/src/java/org/apache/log4j/chainsaw/ChainsawConstants.java
  
  Index: ChainsawConstants.java
  ===
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/ChainsawConstants.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ChainsawConstants.java20 Dec 2003 04:51:52 -  1.7
  +++ ChainsawConstants.java23 Dec 2003 21:44:17 -  1.8
  @@ -117,5 +117,8 @@
 static final String LEVEL_DISPLAY_TEXT = "text";  
   
 static final String DATETIME_FORMAT = "EEE MMM dd HH:mm:ss z ";
  +  
  +//  TODO come up with a better page not found url
  +  public static final URL URL_PAGE_NOT_FOUND = WELCOME_URL;
   
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw/receivers ReceiversPanel.java

2003-12-23 Thread psmith
psmith  2003/12/23 13:44:53

  Modified:src/java/org/apache/log4j/chainsaw/receivers
ReceiversPanel.java
  Log:
  added a relevan title to the dialog.
  
  Revision  ChangesPath
  1.9   +2 -2  
jakarta-log4j/src/java/org/apache/log4j/chainsaw/receivers/ReceiversPanel.java
  
  Index: ReceiversPanel.java
  ===
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/receivers/ReceiversPanel.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ReceiversPanel.java   23 Dec 2003 02:19:14 -  1.8
  +++ ReceiversPanel.java   23 Dec 2003 21:44:53 -  1.9
  @@ -649,8 +649,8 @@
   new AbstractAction("New " + name + "...") {
 public void actionPerformed(ActionEvent e) {
   Container container = 
SwingUtilities.getAncestorOfClass(JFrame.class, ReceiversPanel.this);
  -final JDialog dialog = new JDialog((JFrame) container, true);
  -
  +final JDialog dialog = new JDialog((JFrame) container,"New " + 
toCreate.getName() + "..." ,true);
  +
   try {
 final NewReceiverDialogPanel panel =
   NewReceiverDialogPanel.create(toCreate);
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw/receivers NewReceiverDialogPanel.java

2003-12-23 Thread psmith
psmith  2003/12/23 13:46:06

  Modified:src/java/org/apache/log4j/chainsaw/receivers
NewReceiverDialogPanel.java
  Log:
  Jalopied, and added a JavaDoc viewer inside a JSplitPane for the Plugin
  that is being edited.
  
  Revision  ChangesPath
  1.2   +170 -74   
jakarta-log4j/src/java/org/apache/log4j/chainsaw/receivers/NewReceiverDialogPanel.java
  
  Index: NewReceiverDialogPanel.java
  ===
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/receivers/NewReceiverDialogPanel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NewReceiverDialogPanel.java   22 Dec 2003 11:01:45 -  1.1
  +++ NewReceiverDialogPanel.java   23 Dec 2003 21:46:06 -  1.2
  @@ -49,94 +49,190 @@
   
   package org.apache.log4j.chainsaw.receivers;
   
  +import org.apache.log4j.chainsaw.help.HelpManager;
  +import org.apache.log4j.chainsaw.helper.OkCancelPanel;
  +import org.apache.log4j.chainsaw.messages.MessageCenter;
  +import org.apache.log4j.helpers.LogLog;
  +import org.apache.log4j.net.SocketHubReceiver;
  +import org.apache.log4j.plugins.Plugin;
  +import org.apache.log4j.plugins.Receiver;
  +
   import java.awt.BorderLayout;
  +import java.awt.Dimension;
   import java.awt.event.ActionEvent;
   import java.awt.event.ActionListener;
   
  +import java.beans.PropertyChangeEvent;
  +import java.beans.PropertyChangeListener;
  +
  +import java.io.IOException;
  +
  +import java.net.URL;
  +
   import javax.swing.JDialog;
  +import javax.swing.JEditorPane;
   import javax.swing.JFrame;
   import javax.swing.JPanel;
  +import javax.swing.JScrollPane;
  +import javax.swing.JSplitPane;
   import javax.swing.UIManager;
   
  -import org.apache.log4j.chainsaw.helper.OkCancelPanel;
  -import org.apache.log4j.net.SocketHubReceiver;
  -import org.apache.log4j.plugins.Plugin;
  -import org.apache.log4j.plugins.Receiver;
  -
   
  +/**
  + * A panel that allows a user to configure a new Plugin, and
  + * view that plugins javadoc at the same time
  + *
  + * @author Paul Smith <[EMAIL PROTECTED]>
  + *
  + */
   public class NewReceiverDialogPanel extends JPanel {
  -  private PluginPropertyEditorPanel pluginEditorPanel =
  -new PluginPropertyEditorPanel();
  -  private OkCancelPanel okPanel = new OkCancelPanel();
  -
  -  private NewReceiverDialogPanel() {
  -setupComponents();
  -setupListeners();
  -  }
  -
  -  /**
  -   *
  -   */
  -  private void setupListeners() {
  -  }
  -
  -  /**
  -   *
  -   */
  -  private void setupComponents() {
  -setLayout(new BorderLayout());
  -
  -add(pluginEditorPanel, BorderLayout.CENTER);
  -add(okPanel, BorderLayout.SOUTH);
  -  }
  -
  -  public static NewReceiverDialogPanel create(Class receiverClass)
  -throws Exception {
  -Receiver receiverInstance = (Receiver) receiverClass.newInstance();
  -
  -NewReceiverDialogPanel panel = new NewReceiverDialogPanel();
  -
  -panel.pluginEditorPanel.setPlugin(receiverInstance);
  -
  -return panel;
  -  }
  -
  -  public static void main(String[] args) throws Exception {
  -
  -UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  -
  -NewReceiverDialogPanel panel =
  -  NewReceiverDialogPanel.create(SocketHubReceiver.class);
  -
  -JDialog dialog = new JDialog((JFrame) null, true);
  -dialog.getContentPane().add(panel);
  -
  -ActionListener al =
  -  new ActionListener() {
  -public void actionPerformed(ActionEvent e) {
  -  System.exit(1);
  +
  +private PluginPropertyEditorPanel pluginEditorPanel =
  +new PluginPropertyEditorPanel();
  +private final OkCancelPanel okPanel = new OkCancelPanel();
  +private final JEditorPane javaDocPane = new JEditorPane();
  +private final JScrollPane javaDocScroller = new JScrollPane(javaDocPane);
  +private final JSplitPane splitter = new JSplitPane();
  +
  +private NewReceiverDialogPanel() {
  +setupComponents();
  +setupListeners();
  +}
  +
  +/**
  + *
  + */
  +private void setupListeners() {
  +
  +/**
  + * We listen for the plugin change, and modify the editor panes
  + * url to be the Help resource for that class
  + */
  +pluginEditorPanel.addPropertyChangeListener("plugin",
  +new PropertyChangeListener() {
  +
  +public void propertyChange(PropertyChangeEvent evt) {
  +
  +Plugin plugin = (Plugin) evt.getNewValue();
  +URL url = HelpManager.getInstance().getHelpForClass(
  +plugin.getClass());
  +
  +try {
  +javaDocPane.setPage(url);
  +} catch (IOException e) {
  +MessageCenter.getInstance().getLogger().error(
  +  

cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw/helper SwingHelper.java

2003-12-23 Thread psmith
psmith  2003/12/23 14:22:53

  Modified:src/java/org/apache/log4j/chainsaw/helper SwingHelper.java
  Log:
  added a helper method to create a standard Cancel
  dialog action.
  
  Revision  ChangesPath
  1.2   +34 -0 
jakarta-log4j/src/java/org/apache/log4j/chainsaw/helper/SwingHelper.java
  
  Index: SwingHelper.java
  ===
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/helper/SwingHelper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SwingHelper.java  22 Dec 2003 10:59:23 -  1.1
  +++ SwingHelper.java  23 Dec 2003 22:22:53 -  1.2
  @@ -52,6 +52,16 @@
   import java.awt.Component;
   import java.awt.Dimension;
   import java.awt.Toolkit;
  +import java.awt.event.ActionEvent;
  +import java.awt.event.KeyEvent;
  +
  +import javax.swing.AbstractAction;
  +import javax.swing.Action;
  +import javax.swing.InputMap;
  +import javax.swing.JButton;
  +import javax.swing.JComponent;
  +import javax.swing.JDialog;
  +import javax.swing.KeyStroke;
   
   /**
* A collection of standard utility methods for use within Swing.
  @@ -70,5 +80,29 @@
   component.setLocation(
 (screenSize.width / 2) - (component.getWidth() / 2),
 (screenSize.height / 2) - (component.getHeight() / 2));
  +  }
  +  
  +  /**
  +   * This method configures a standard Cancel action, bound to the ESC key, to 
dispose of the dialog,
  +   * and sets the buttons action to be this action, and adds the action to the 
dialog's rootPane 
  +   * action map
  +   * @param dialog
  +   * @param cancelButton
  +   */
  +  public static void configureCancelForDialog(final JDialog dialog, JButton 
cancelButton) {
  +String CANCEL_ACTION_KEY = "CANCEL_ACTION_KEY";
  +int noModifiers = 0;
  +KeyStroke escapeKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, noModifiers, 
false);
  +InputMap inputMap = 
dialog.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
  +inputMap.put(escapeKey, CANCEL_ACTION_KEY);
  +
  +Action closeAction = new AbstractAction("Cancel") {
  +
  +  public void actionPerformed(ActionEvent arg0) {
  +dialog.dispose();
  +  }};
  +cancelButton.setAction(closeAction);
  +dialog.getRootPane().getActionMap().put(CANCEL_ACTION_KEY, closeAction);
  +
 }
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw/receivers ReceiversPanel.java

2003-12-23 Thread psmith
psmith  2003/12/23 14:24:02

  Modified:src/java/org/apache/log4j/chainsaw/receivers
ReceiversPanel.java
  Log:
  now uses the standard dialog cancel metaphor.
  
  Revision  ChangesPath
  1.10  +10 -6 
jakarta-log4j/src/java/org/apache/log4j/chainsaw/receivers/ReceiversPanel.java
  
  Index: ReceiversPanel.java
  ===
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/receivers/ReceiversPanel.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ReceiversPanel.java   23 Dec 2003 21:44:53 -  1.9
  +++ ReceiversPanel.java   23 Dec 2003 22:24:02 -  1.10
  @@ -658,12 +658,16 @@
 dialog.pack();
 SwingHelper.centerOnScreen(dialog);
   
  -  panel.getOkPanel().getCancelButton().addActionListener(
  -new ActionListener() {
  -  public void actionPerformed(ActionEvent e) {
  -dialog.dispose();
  -  }
  -});
  +  /**
  +   * Make the default button the ok button
  +   */
  +  
dialog.getRootPane().setDefaultButton(panel.getOkPanel().getOkButton());
  +  
  +  /**
  +   * Use the standard Cancel metaphor
  +   */
  +  SwingHelper.configureCancelForDialog(dialog, 
panel.getOkPanel().getCancelButton());
  +  
   
 panel.getOkPanel().getOkButton().addActionListener(
   new ActionListener() {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw/prefs AbstractSettingsEvent.java SaveSettingsEvent.java SettingsManager.java

2003-12-23 Thread psmith
psmith  2003/12/23 20:06:17

  Modified:src/java/org/apache/log4j/chainsaw/prefs
SaveSettingsEvent.java SettingsManager.java
  Added:   src/java/org/apache/log4j/chainsaw/prefs
AbstractSettingsEvent.java
  Log:
  Added an abstract class to assist with settings stuff.
  
  A settings event now contains a reference to the settings
  directory.
  
  This allows components to store their preferences a different
  way (say, XML), but still partake in the general Settings framework.
  
  Revision  ChangesPath
  1.3   +8 -5  
jakarta-log4j/src/java/org/apache/log4j/chainsaw/prefs/SaveSettingsEvent.java
  
  Index: SaveSettingsEvent.java
  ===
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/prefs/SaveSettingsEvent.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SaveSettingsEvent.java11 Dec 2003 02:56:08 -  1.2
  +++ SaveSettingsEvent.java24 Dec 2003 04:06:17 -  1.3
  @@ -48,17 +48,19 @@
*/
   package org.apache.log4j.chainsaw.prefs;
   
  +import java.io.File;
   import java.util.Properties;
   
   /**
* @author Paul Smith <[EMAIL PROTECTED]>
*
*/
  -public class SaveSettingsEvent extends SettingsEvent {
  +public class SaveSettingsEvent extends AbstractSettingsEvent {
   
  - SaveSettingsEvent(Object source) {
  - super(source);
  - }
  +  
  +  SaveSettingsEvent(Object source, File settingsLocation) {
  + super(source, settingsLocation);
  + }

public void saveSetting(String key, int value) {
saveSetting(key, "" + value);
  @@ -79,7 +81,8 @@
Properties getProperties() {
return properties;
}
  - private Properties properties = new Properties();
  +  
  +  private Properties properties = new Properties();
 /**
  * @param string
  * @param b
  
  
  
  1.4   +2 -2  
jakarta-log4j/src/java/org/apache/log4j/chainsaw/prefs/SettingsManager.java
  
  Index: SettingsManager.java
  ===
  RCS file: 
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/prefs/SettingsManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SettingsManager.java  16 Dec 2003 09:23:48 -  1.3
  +++ SettingsManager.java  24 Dec 2003 04:06:17 -  1.4
  @@ -263,7 +263,7 @@
   
   if (settingsListener instanceof Profileable) {
   Profileable profileable = (Profileable) settingsListener;
  -event = new SaveSettingsEvent(this);
  +event = new SaveSettingsEvent(this, getSettingsDirectory());
   
   profileable.saveSettings(event);
   
  @@ -298,7 +298,7 @@
   
   if (!(settingsListener instanceof Profileable)) {
   if (event == null) {
  -event = new SaveSettingsEvent(this);
  +event = new SaveSettingsEvent(this, getSettingsDirectory());
   }
   
   settingsListener.saveSettings(event);
  
  
  
  1.1  
jakarta-log4j/src/java/org/apache/log4j/chainsaw/prefs/AbstractSettingsEvent.java
  
  Index: AbstractSettingsEvent.java
  ===
  /*
   */
  package org.apache.log4j.chainsaw.prefs;
  
  import java.io.File;
  import java.util.EventObject;
  
  /**
   * @author psmith
   *
   */
  class AbstractSettingsEvent extends EventObject {

private final File settingsLocation;


/**
 * @param source
 */
public AbstractSettingsEvent(Object source, File settingsLocation) {
  super(source);
  this.settingsLocation = settingsLocation;
  
}
  
public File getSettingsLocation() {
  return this.settingsLocation;
}
  }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw/favourites - New directory

2003-12-23 Thread psmith
psmith  2003/12/23 20:08:40

  jakarta-log4j/src/java/org/apache/log4j/chainsaw/favourites - New directory

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw/favourites package.html Favourite.java FavouritesRegistry.java

2003-12-23 Thread psmith
psmith  2003/12/23 20:08:45

  Added:   src/java/org/apache/log4j/chainsaw/favourites package.html
Favourite.java FavouritesRegistry.java
  Log:
  The beginnings of Favourites (save Plugin state).
  
  Eventually the saved state of a prototype plugin will
  re-use the  syntax that is found in a
  log4j.xml file.
  
  Revision  ChangesPath
  1.1  
jakarta-log4j/src/java/org/apache/log4j/chainsaw/favourites/package.html
  
  Index: package.html
  ===
  
   
  
  
  
  
  
  The Favourites package.
  
  
  Prototype Rules
  The following rules are checked against a potential prototype instance to ensure it 
can
  be used and saved for later use:
  
  
 Have a public no-arg constructor available
 TODO - more rules
  
   
  
  
  
  1.1  
jakarta-log4j/src/java/org/apache/log4j/chainsaw/favourites/Favourite.java
  
  Index: Favourite.java
  ===
  package org.apache.log4j.chainsaw.favourites;
  
  /**
   * A Fauvourite is just a named container of on object that can be used
   * as a basis (prototype) for the creation of exact copies.
   * 
   * Clients should use the FavouritesRegistry to create instances of this class
   * so that explicit checks can be performed about the suitability of the
   * prototype.
   * 
   * @author Paul Smith <[EMAIL PROTECTED]>
   *
   */
  public final class Favourite {
  
  private String name;
  private Object prototype;
  
  /**
   * @param name
   * @param object
   */
  Favourite(String name, Object prtotype) {
  this.name = name;
  this.prototype = prtotype;
  }
  
  
  /**
   * @return Returns the name.
   */
  public final String getName() {
  
  return name;
  }
  
  /**
   * Returns the object that would be used as a basis to create new
   * instances of that same object.
   * @return Returns the prototype.
   */
  public final Object getPrototype() {
return prototype;
  }
  }
  
  
  
  1.1  
jakarta-log4j/src/java/org/apache/log4j/chainsaw/favourites/FavouritesRegistry.java
  
  Index: FavouritesRegistry.java
  ===
  package org.apache.log4j.chainsaw.favourites;
  
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.Collections;
  import java.util.List;
  
  /**
   *  A singleton class that is used as a Registry of instances of JavaBeans 
   * that are in a state that a user prefers.
   * 
   * @author Paul Smith <[EMAIL PROTECTED]>
   *
   */
  public class FavouritesRegistry{

private final FavouritesRegistry instance = new FavouritesRegistry();
private final List favourites = new ArrayList();

/**
 * Returns a Collection of Favourite instances whose getPrototype() method
 * returns an object whose class is assignable from clazz, or more formally, such 
that
 * clazz.isAssignableFrom(favourite.getPrototype().getClass())
 * @param clazz
 * @return
 */
public synchronized Collection getFavouritesByClass(Class clazz) {
  throw new UnsupportedOperationException("Work In Progress");
}

/**
 * Adds a favourite to this Registry
 * @param favourite
 */

public synchronized void addFavourite(Favourite favourite) {
  throw new UnsupportedOperationException("Work In Progress");
}

/**
 * Returns an unmodifiable List of all the known Favourite instances
 * @return
 */
public List getFavourites() {
  return Collections.unmodifiableList(favourites);
}

/**
 * Creates a new Favourite instance after running throught some
 * suitability checks to make sure the object class is ok to be used
 * as a prototype.
 * 
 * @param name The name to use for the favourite
 * @param prototype The object to register
 * @throws IllegalArgumentException if the prototype does not conform
 * to the necessary rules to be used as a prototype (see the package 
documentation).
 * 
 * @return
 */
public void addFavourite(String name, Object prototype) {
  favourites.add(createFavourite(name, prototype));
}

private Favourite createFavourite(String name, Object prototype) {
  checkSuitability(prototype);
  return new Favourite(name, prototype);
}

/**
 * Checks the suitability of an object to make sure it conforms to all the rules
 * for being a prototype,
 * @param prototype
 * @throws IllegalArgumentException if the prototype is not suitable
 */
private void checkSuitability(Object prototype)  throws IllegalArgumentException{
  // TODO Auto-generated method stub
 throw new UnsupportedOperationException("Work in Progress"); 
}
  
p