Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2659 - in development/main: depot/console depot/console/src/main/net/dpml/depot/lang depot/prefs depot/prefs/src/main/net/dpml/depot/prefs depot/prefs/src/main/net/dpml/depot/prefs/images depot/station/src/main/net/dpml/depot/prefs depot/station/src/main/net/dpml/depot/prefs/images transit/core/handler/src/main/net/dpml/transit transit/core/handler/src/main/net/dpml/transit/cache transit/core/handler/src/main/net/dpml/transit/host transit/core/handler/src/main/net/dpml/transit/manager transit/core/handler/src/test/net/dpml/transit/manager

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT dpml.net
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r2659 - in development/main: depot/console depot/console/src/main/net/dpml/depot/lang depot/prefs depot/prefs/src/main/net/dpml/depot/prefs depot/prefs/src/main/net/dpml/depot/prefs/images depot/station/src/main/net/dpml/depot/prefs depot/station/src/main/net/dpml/depot/prefs/images transit/core/handler/src/main/net/dpml/transit transit/core/handler/src/main/net/dpml/transit/cache transit/core/handler/src/main/net/dpml/transit/host transit/core/handler/src/main/net/dpml/transit/manager transit/core/handler/src/test/net/dpml/transit/manager
  • Date: Mon, 23 May 2005 16:04:04 +0000

Author: mcconnell AT dpml.net
Date: Mon May 23 16:03:51 2005
New Revision: 2659

Added:

development/main/depot/prefs/src/main/net/dpml/depot/prefs/CacheDirectoryPanel.java
- copied, changed from r2653,
development/main/depot/prefs/src/main/net/dpml/depot/prefs/CachePanel.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/CacheManagerPanel.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/CacheTableModel.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/ClassicCellRenderer.java
- copied, changed from r2653,
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DefaultCellRenderer.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/ClassicCredentialsPanel.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/ClassicDialog.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/ClassicPanel.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/ClassicTable.java
- copied, changed from r2653,
development/main/depot/prefs/src/main/net/dpml/depot/prefs/GenericTable.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/HostManagerPanel.java
- copied, changed from r2653,
development/main/depot/prefs/src/main/net/dpml/depot/prefs/TransitResourceHostPanel.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/PasswordAuthenticationEvent.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/PasswordAuthenticationListener.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/PasswordAuthenticationModel.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/PluginManagerPanel.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyExcludeEditPanel.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyExcludesTableModel.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyFeaturesPanel.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyManagerPanel.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/RegistryManagerPanel.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/RegistryTableModel.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/images/proxy.png
(contents, props changed)

development/main/depot/station/src/main/net/dpml/depot/prefs/ProxyPanel.java

development/main/depot/station/src/main/net/dpml/depot/prefs/images/proxy.png
(contents, props changed)
Removed:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/CachePanel.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/ContentHandlerMainPanel.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/DefaultCellRenderer.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotPreferencesDialog.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/GenericTable.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/GenericTableModel.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/PluginSetupPanel.java
development/main/depot/prefs/src/main/net/dpml/depot/prefs/TODO.TXT

development/main/depot/prefs/src/main/net/dpml/depot/prefs/TransitPanel.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/TransitResourceHostPanel.java
Modified:
development/main/depot/console/build.xml
development/main/depot/console/src/main/net/dpml/depot/lang/Main.java
development/main/depot/prefs/ (props changed)

development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotPreferencesFrame.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotPreferencesPanel.java
development/main/depot/prefs/src/main/net/dpml/depot/prefs/Main.java

development/main/depot/station/src/main/net/dpml/depot/prefs/TransitPanel.java

development/main/transit/core/handler/src/main/net/dpml/transit/TransitPreferences.java

development/main/transit/core/handler/src/main/net/dpml/transit/cache/FileCacheHandler.java

development/main/transit/core/handler/src/main/net/dpml/transit/host/PreferencesResourceManager.java

development/main/transit/core/handler/src/main/net/dpml/transit/manager/CacheManager.java

development/main/transit/core/handler/src/main/net/dpml/transit/manager/HostManager.java

development/main/transit/core/handler/src/main/net/dpml/transit/manager/PluginManager.java

development/main/transit/core/handler/src/main/net/dpml/transit/manager/RegistryManager.java

development/main/transit/core/handler/src/test/net/dpml/transit/manager/ProxyManagerTestCase.java
Log:
Synchronize Depot preferences management with the Transit management model.

Modified: development/main/depot/console/build.xml
==============================================================================
--- development/main/depot/console/build.xml (original)
+++ development/main/depot/console/build.xml Mon May 23 16:03:51 2005
@@ -11,10 +11,9 @@
<x:filter token="DEPOT-PATH" feature="filename"/>
<x:filter token="TRANSIT-PATH" key="dpml-transit-main"
feature="filename"/>
<x:property name="transit.filename" key="dpml-transit-main"
feature="filename"/>
- <x:property name="station.filename" key="dpml-depot-station"
feature="filename"/>
- <echo>${station.filename}</echo>
+ <x:property name="prefs.filename" key="dpml-depot-prefs"
feature="filename"/>
<filter token="TRANSIT-MAIN-LIB" value="${transit.filename}" />
- <filter token="DEPOT-STATION-LIB" value="${station.filename}" />
+ <filter token="DEPOT-PREFS-LIB" value="${prefs.filename}" />
<property name="project.jar.classpath" value="${transit.filename}" />
</target>


Modified:
development/main/depot/console/src/main/net/dpml/depot/lang/Main.java
==============================================================================
--- development/main/depot/console/src/main/net/dpml/depot/lang/Main.java
(original)
+++ development/main/depot/console/src/main/net/dpml/depot/lang/Main.java
Mon May 23 16:03:51 2005
@@ -302,7 +302,7 @@
defaultProfile.put( "classname", "net.dpml.depot.prefs.Main" );
defaultProfile.put( "title", "Depot Preferences" );
Preferences classpath = defaultProfile.node( "classpath" );
- classpath.put( "dpml-depot-station",
"${dpml.data}/lib/@DEPOT-STATION-LIB@" );
+ classpath.put( "dpml-depot-prefs",
"${dpml.data}/lib/@DEPOT-PREFS-LIB@" );
return defaultProfile;
}
}

Copied:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/CacheDirectoryPanel.java
(from r2653,
development/main/depot/prefs/src/main/net/dpml/depot/prefs/CachePanel.java)
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/CachePanel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/CacheDirectoryPanel.java
Mon May 23 16:03:51 2005
@@ -26,9 +26,6 @@
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.File;
-import java.util.prefs.PreferenceChangeEvent;
-import java.util.prefs.PreferenceChangeListener;
-import java.util.prefs.Preferences;

import javax.swing.AbstractAction;
import javax.swing.JButton;
@@ -40,7 +37,10 @@

import net.dpml.depot.lang.DPML;
import net.dpml.transit.Transit;
-import net.dpml.transit.cache.CacheHandler;
+import net.dpml.transit.manager.CacheManager;
+import net.dpml.transit.model.CacheListener;
+import net.dpml.transit.model.FileChangeEvent;
+import net.dpml.transit.model.HostNodeEvent;


/**
@@ -48,7 +48,7 @@
*
* @author <a href="mailto:mcconnell AT osm.net";>OSM</a>
*/
-class CachePanel extends JPanel implements PreferenceChangeListener,
PropertyChangeListener
+class CacheDirectoryPanel extends ClassicPanel implements CacheListener,
PropertyChangeListener
{
//--------------------------------------------------------------
// static
@@ -67,7 +67,7 @@

private File m_target;

- private Preferences m_cachePrefs;
+ private CacheManager m_manager;

private PropertyChangeSupport m_propertyChangeSupport;

@@ -75,28 +75,25 @@
// constructor
//--------------------------------------------------------------

- public CachePanel( JDialog parent ) throws Exception
+ public CacheDirectoryPanel( JDialog parent, CacheManager manager )
throws Exception
{
m_parent = parent;
- m_propertyChangeSupport = new PropertyChangeSupport( this );
-
- m_cachePrefs = Preferences.userNodeForPackage( CacheHandler.class );
+ m_manager = manager;

- setLayout( new BorderLayout() );
- setBackground( Color.white );
+ m_propertyChangeSupport = new PropertyChangeSupport( this );

File cache = getCurrentCacheFile();
String filename = cache.getCanonicalPath();
-
JLabel label =
IconHelper.createImageIconJLabel(
getClass().getClassLoader(),
"net/dpml/depot/prefs/images/cache.jpg", "Filename", "Directory: " + filename
);
label.setBorder( new EmptyBorder( 0, 5, 0, 0 ) );
+
m_label = label;
m_ok = new JButton( new OKAction( "OK" ) );
m_revert = new JButton( new RevertAction( "Undo" ) );

- m_cachePrefs.addPreferenceChangeListener( this );
+ m_manager.addCacheListener( this );

if( null == cache )
{
@@ -127,6 +124,44 @@
m_propertyChangeSupport.addPropertyChangeListener( this );
}
}
+
+
//--------------------------------------------------------------------------
+ // CacheListener
+
//--------------------------------------------------------------------------
+
+ /**
+ * Notify the listener of a change to the cache directory.
+ * @param event the cache directory change event
+ */
+ public void cacheDirectoryChanged( FileChangeEvent event )
+ {
+ File cache = getCurrentCacheFile();
+ String path = convertToPath( cache );
+ String text = "Directory: " + path;
+ m_label.setText( text );
+ }
+
+ /**
+ * Notify the listener of the addition of a new host.
+ * @param event the host added event
+ */
+ public void hostAdded( HostNodeEvent event )
+ {
+ // ignore
+ }
+
+ /**
+ * Notify the listener of the removal of a host.
+ * @param event the host removed event
+ */
+ public void hostRemoved( HostNodeEvent event )
+ {
+ // ignore
+ }
+
+
//--------------------------------------------------------------------------
+ // PropertyChangeListener
+
//--------------------------------------------------------------------------

/**
* The actions dealing with changes to the dialog raise change events
that
@@ -142,17 +177,6 @@
m_revert.setEnabled( flag );
}

- public void preferenceChange( PreferenceChangeEvent event )
- {
- if( null == m_target )
- {
- File cache = getCurrentCacheFile();
- String path = convertToPath( cache );
- String text = "Directory: " + path;
- m_label.setText( text );
- }
- }
-
private class CloseAction extends AbstractAction
{
CloseAction( String name )
@@ -163,15 +187,6 @@
public void actionPerformed( ActionEvent event )
{
m_parent.hide();
- if( m_target != null )
- {
- File cache = getCurrentCacheFile();
- String filename = convertToPath( cache );
- final String text = "Directory: " + filename;
- m_label.setText( text );
- m_target = null;
- }
- m_ok.setEnabled( false );
}
}

@@ -191,7 +206,7 @@
if( false == file.equals( m_target ) )
{
String path = convertToPath( m_target );
- m_cachePrefs.put( "location", path );
+ m_manager.setCacheDirectory( new File( path ) );
}
}
m_parent.hide();
@@ -260,41 +275,6 @@

private File getCurrentCacheFile()
{
- File file = getUserCacheFile();
- if( null == file )
- {
- return getDefaultCacheFile();
- }
- else
- {
- return file;
- }
- }
-
- private File getUserCacheFile()
- {
- String filename = m_cachePrefs.get( "location", null );
- if( null == filename )
- {
- return new File( DPML.DPML_DATA, "cache" );
- }
- else
- {
- return new File( filename );
- }
- }
-
- private File getDefaultCacheFile()
- {
- Preferences node = Preferences.systemNodeForPackage(
CacheHandler.class );
- String filename = node.get( "location", null );
- if( null == filename )
- {
- throw new IllegalStateException( "missing system location
preference: " + node );
- }
- else
- {
- return new File( filename );
- }
+ return m_manager.getCacheDirectory();
}
}

Added:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/CacheManagerPanel.java
==============================================================================
--- (empty file)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/CacheManagerPanel.java
Mon May 23 16:03:51 2005
@@ -0,0 +1,343 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.depot.prefs;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.Window;
+import java.awt.Dialog;
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.logging.Logger;
+import java.util.logging.Level;
+
+import javax.swing.AbstractAction;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.TitledBorder;
+import javax.swing.table.DefaultTableColumnModel;
+import javax.swing.table.TableColumn;
+import javax.swing.table.TableColumnModel;
+
+import net.dpml.transit.Transit;
+import net.dpml.transit.util.ExceptionHelper;
+import net.dpml.transit.manager.CacheManager;
+import net.dpml.transit.manager.HostManager;
+
+/**
+ * Runnable plugin that handles DPML environment setup.
+ *
+ * @author <a href="mailto:mcconnell AT osm.net";>OSM</a>
+ */
+class CacheManagerPanel extends ClassicPanel implements
PropertyChangeListener
+{
+ //--------------------------------------------------------------
+ // static
+ //--------------------------------------------------------------
+
+ static EmptyBorder border5 = new EmptyBorder( 5, 5, 5, 5);
+
+ //--------------------------------------------------------------
+ // state
+ //--------------------------------------------------------------
+
+ private final Window m_parent;
+
+ private ClassicTable m_table;
+ private EditAction m_editAction;
+ private JButton m_edit;
+ private JButton m_delete;
+ private String m_selection; // selected hostname
+ private CacheManager m_manager;
+
+ //--------------------------------------------------------------
+ // constructor
+ //--------------------------------------------------------------
+
+ public CacheManagerPanel( Window parent, CacheManager manager ) throws
Exception
+ {
+ Transit.getInstance();
+
+ m_parent = parent;
+ m_manager = manager;
+
+ m_editAction = new EditAction( "Edit" );
+ m_edit = new JButton( m_editAction );
+ m_delete = new JButton( new DeleteAction( "Delete" ) );
+
+ JLabel label =
+ IconHelper.createImageIconJLabel(
+ getClass().getClassLoader(), CACHE_IMG_PATH,
+ "Cache", "Cache handler properties and settings." );
+ label.setBorder( new EmptyBorder( 0, 5, 0, 0 ) );
+ CacheAction action = new CacheAction( "Cache" );
+ getHeader().addEntry( label, "Local Cache", new JButton( action ) );
+
+ JPanel hostPanel = new JPanel();
+ hostPanel.setBackground( Color.white );
+ hostPanel.setLayout( new BorderLayout() );
+ TitledBorder tb =
+ new TitledBorder(
+ new EmptyBorder( 0,0,0,0 ), "Resource Hosts", TitledBorder.LEFT,
TitledBorder.TOP );
+ hostPanel.setBorder( new CompoundBorder( tb, border5 ) );
+
+ TableColumnModel columns = createHostsColumnModel();
+ CacheTableModel tableModel = new CacheTableModel( manager );
+ m_table = new ClassicTable( tableModel, columns );
+ m_table.addPropertyChangeListener( this );
+ m_table.setShowVerticalLines( false );
+ m_table.setShowHorizontalLines( false );
+
+ JScrollPane scroller = createScrollPanel( m_table );
+ hostPanel.add( scroller, BorderLayout.CENTER );
+ JPanel buttonHolder = new JPanel();
+ buttonHolder.setLayout( new FlowLayout( FlowLayout.RIGHT ) );
+ buttonHolder.add( new JButton( new AddAction( "Add" ) ) );
+ buttonHolder.add( m_edit );
+ buttonHolder.add( m_delete );
+ buttonHolder.setBorder( new EmptyBorder( 10, 10, 5, 0 ) );
+ buttonHolder.setBackground( Color.white );
+ hostPanel.add( buttonHolder, BorderLayout.SOUTH );
+
+ getBody().add( hostPanel, BorderLayout.CENTER );
+ }
+
+ /**
+ * handle property change events raised by the table model.
+ */
+ public void propertyChange( PropertyChangeEvent event )
+ {
+ if( "selection".equals( event.getPropertyName() ) )
+ {
+ m_selection = (String) event.getNewValue();
+ if( null != m_selection )
+ {
+ m_edit.setEnabled( true );
+ m_delete.setEnabled( true );
+ getRootPane().setDefaultButton( m_edit );
+ }
+ else
+ {
+ m_edit.setEnabled( false );
+ m_delete.setEnabled( false );
+ }
+ }
+ else if( "doubleclick".equals( event.getPropertyName() ) )
+ {
+ m_editAction.editSelectedHost( m_edit );
+ }
+ }
+
+ private class CacheAction extends AbstractAction
+ {
+ CacheAction( String name )
+ {
+ super( name );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ try
+ {
+ final String title = "Resource Cache";
+ final Dimension size = new Dimension( 400, 160 );
+ ClassicDialog dialog = ClassicDialog.createDialog( m_parent,
title, size );
+ CacheDirectoryPanel panel = new CacheDirectoryPanel( dialog,
m_manager );
+ dialog.getBody().add( panel );
+ dialog.setLocationRelativeTo( (Component) event.getSource()
);
+ dialog.setResizable( false );
+ dialog.setVisible(true);
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to handle the 'Cache'
action. "
+ + "\nCODEBASE: "
+ +
getClass().getProtectionDomain().getCodeSource().getLocation().toString();
+ Logger logger = Logger.getLogger( "depot.prefs" );
+ logger.log( Level.SEVERE, error, e );
+ }
+ }
+ }
+
+ //--------------------------------------------------------------
+ // utilities
+ //--------------------------------------------------------------
+
+ private static JPanel createLabel( String name )
+ {
+ JLabel label = new JLabel( name );
+ label.setBorder( new EmptyBorder( 10, 10, 10, 10 ) );
+ JPanel panel = new JPanel( new FlowLayout( FlowLayout.LEFT ) );
+ panel.add( label );
+ return panel;
+ }
+
+ /**
+ * Creation of a parameterized scroll pane.
+ * @param view the viewport view
+ * @return the scroll pane wrapping the supplied view
+ */
+ private static JScrollPane createScrollPanel( Component view )
+ {
+ JScrollPane scroller = new JScrollPane();
+ scroller.setVerticalScrollBarPolicy(
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED );
+ scroller.setHorizontalScrollBarPolicy(
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ scroller.getViewport().setBackground( Color.white );
+ scroller.setViewportView( view );
+ return scroller;
+ }
+
+ /**
+ * Utility method to construct the hosts table column model.
+ * @return the table
+ */
+ private static TableColumnModel createHostsColumnModel()
+ {
+ TableColumn iconColumn = new TableColumn( 0, 30, new
ClassicCellRenderer(), null );
+ iconColumn.setHeaderValue("");
+ iconColumn.setMaxWidth( 30 );
+ iconColumn.setMinWidth( 30 );
+ TableColumn hostColumn = new TableColumn( 1, 100, new
ClassicCellRenderer(), null );
+ hostColumn.setHeaderValue("Host");
+ TableColumnModel columnModel = new DefaultTableColumnModel();
+ columnModel.addColumn( iconColumn );
+ columnModel.addColumn( hostColumn );
+ return columnModel;
+ }
+
+ private class AddAction extends AbstractAction
+ {
+ public AddAction( String name )
+ {
+ super( name );
+ setEnabled( true );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ // TODO: create a dialog that collects the host name and the
base url
+ // and use this to create a new host entry then lauch the host
edit
+ // dialog box. The following is just a placeholder that does
nothing
+ // useful.
+
+ String name = JOptionPane.showInputDialog( m_parent, "Host
name:" );
+ if( null != name )
+ {
+ m_manager.addHostModel( name );
+ }
+ }
+ }
+
+ private class EditAction extends AbstractAction
+ {
+ public EditAction( String name )
+ {
+ super( name );
+ setEnabled( false );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ editSelectedHost( (Component) event.getSource() );
+ }
+
+ public void editSelectedHost( Component source)
+ {
+ try
+ {
+ JDialog dialog = null;
+ if( m_parent instanceof Dialog )
+ {
+ dialog = new JDialog( (Dialog) m_parent, true );
+ }
+ else
+ {
+ dialog = new JDialog( (Frame) m_parent, true );
+ }
+ dialog.setTitle( "Resource Host: " + m_selection );
+ HostManager manager = m_manager.getHostManager( m_selection
);
+ JPanel panel = new HostManagerPanel( dialog, manager );
+ dialog.setContentPane( panel );
+ Dimension size = new Dimension( 400, 360 );
+ dialog.setSize( size );
+ dialog.setLocationRelativeTo( source );
+ dialog.setResizable( true );
+ dialog.setVisible( true );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to construct host
dialog."
+ + "\nCODEBASE: "
+ +
CacheManagerPanel.class.getProtectionDomain().getCodeSource().getLocation().toString();
+ Logger logger = Logger.getLogger( "depot.prefs" );
+ logger.log( Level.SEVERE, error, e );
+ }
+ }
+ }
+
+ private class DeleteAction extends AbstractAction
+ {
+ public DeleteAction( String name )
+ {
+ super( name );
+ setEnabled( false );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ if( null == m_selection )
+ {
+ return;
+ }
+
+ try
+ {
+ m_manager.removeHostModel( m_selection );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to delete a host
preferences node."
+ + "\nCODEBASE: "
+ +
CacheManagerPanel.class.getProtectionDomain().getCodeSource().getLocation().toString();
+ Logger logger = Logger.getLogger( "depot.prefs" );
+ logger.log( Level.SEVERE, error, e );
+ }
+ }
+ }
+
+ private static String CACHE_IMG_PATH =
"net/dpml/depot/prefs/images/cache.jpg";
+
+}

Added:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/CacheTableModel.java
==============================================================================
--- (empty file)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/CacheTableModel.java
Mon May 23 16:03:51 2005
@@ -0,0 +1,191 @@
+/*
+ * Copyright 2005 Stephen McConnell
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.depot.prefs;
+
+import javax.swing.Icon;
+import javax.swing.table.AbstractTableModel;
+
+import net.dpml.transit.Transit;
+import net.dpml.transit.model.FileChangeEvent;
+import net.dpml.transit.model.HostNodeEvent;
+import net.dpml.transit.model.CacheListener;
+import net.dpml.transit.manager.CacheManager;
+
+/**
+ * Table model that maps table rows to child nodes of a supplied preferences
node.
+ */
+public class CacheTableModel extends AbstractTableModel implements
CacheListener
+{
+
//--------------------------------------------------------------------------
+ // static
+
//--------------------------------------------------------------------------
+
+ /**
+ * Default small icon path.
+ */
+ private static final String ICON_PATH =
"net/dpml/depot/prefs/images/item.gif";
+
+ /**
+ * Constant row identifier for the icon.
+ */
+ public static final int ICON = 0;
+
+ /**
+ * Constant row identifier for the name.
+ */
+ public static final int VALUE = 1;
+
+ /**
+ * Number of columns.
+ */
+ private static final int COLUMN_COUNT = 2;
+
+ /**
+ * Default small icon.
+ */
+ private static final Icon FEATURE_ICON =
+ IconHelper.createImageIcon(
+ RegistryTableModel.class.getClassLoader(), ICON_PATH, "Features" );
+
+ private final CacheManager m_manager;
+
+
//--------------------------------------------------------------------------
+ // constructor
+
//--------------------------------------------------------------------------
+
+ /**
+ * Creation of a new table model that presents children of the supplied
preference
+ * node as table entries.
+ *
+ * @param prefs the preferences node that this model is displaying
+ */
+ public CacheTableModel( CacheManager manager )
+ {
+ super();
+ m_manager = manager;
+ manager.addCacheListener( this );
+ }
+
+ protected void finalize()
+ {
+ try
+ {
+ m_manager.removeCacheListener( this );
+ }
+ catch( Throwable e )
+ {
+ }
+ }
+
+
//--------------------------------------------------------------------------
+ // CacheListener
+
//--------------------------------------------------------------------------
+
+ /**
+ * Notify the listener of a change to the cache directory.
+ * @param event the cache directory change event
+ */
+ public void cacheDirectoryChanged( FileChangeEvent event )
+ {
+ // ignore
+ }
+
+ /**
+ * Notify the listener of the addition of a new host.
+ * @param event the host added event
+ */
+ public void hostAdded( HostNodeEvent event )
+ {
+ fireTableStructureChanged();
+ }
+
+ /**
+ * Notify the listener of the removal of a host.
+ * @param event the host removed event
+ */
+ public void hostRemoved( HostNodeEvent event )
+ {
+ fireTableStructureChanged();
+ }
+
+
//--------------------------------------------------------------------------
+ // NodeTableModel
+
//--------------------------------------------------------------------------
+
+ /**
+ * Returns the number of model columns.
+ * @return int the number of columns maintained by the model
+ */
+ public int getColumnCount()
+ {
+ return COLUMN_COUNT;
+ }
+
+ /**
+ * Returns the number of rows in the model. The value returned is
+ * equivilent to the number of elements in the list backing the model.
+ * @return int the number of rows maintained by the model
+ */
+ public int getRowCount()
+ {
+ try
+ {
+ return m_manager.getHostModels().length;
+ }
+ catch( Throwable e )
+ {
+ return 0;
+ }
+ }
+
+ /**
+ * Returns the feature object at the request column and row combination.
+ * If the col index is out of range the method returns the agent
corresponding
+ * to the row identifier.
+ * @param row the row index
+ * @param col the column index
+ * @return Object
+ */
+ public Object getValueAt( int row, int col )
+ {
+ Object result = "";
+ if( row > getRowCount() )
+ {
+ return result;
+ }
+
+ switch( col )
+ {
+ case ICON :
+ return FEATURE_ICON;
+ default:
+ return getHostAtRow( row );
+ }
+ }
+
+ private String getHostAtRow( int row )
+ {
+ try
+ {
+ return m_manager.getHostModels()[ row ].getID();
+ }
+ catch( Throwable e )
+ {
+ return "";
+ }
+ }
+}

Copied:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ClassicCellRenderer.java
(from r2653,
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DefaultCellRenderer.java)
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DefaultCellRenderer.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ClassicCellRenderer.java
Mon May 23 16:03:51 2005
@@ -26,7 +26,7 @@
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableCellRenderer;

-class DefaultCellRenderer extends DefaultTableCellRenderer
+class ClassicCellRenderer extends DefaultTableCellRenderer
{

//--------------------------------------------------------------------------
// state
@@ -41,7 +41,7 @@
/**
* Creation of a new cell renderer using the default font.
*/
- public DefaultCellRenderer( )
+ public ClassicCellRenderer( )
{
}


Added:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ClassicCredentialsPanel.java
==============================================================================
--- (empty file)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ClassicCredentialsPanel.java
Mon May 23 16:03:51 2005
@@ -0,0 +1,338 @@
+/*
+ * Copyright 2005 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.depot.prefs;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.net.ContentHandler;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.PasswordAuthentication;
+
+import javax.swing.AbstractAction;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.JPasswordField;
+import javax.swing.ImageIcon;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.TitledBorder;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+
+/**
+ * Control panel for editing the cache preferences.
+ *
+ * @author <a href="mailto:mcconnell AT osm.net";>OSM</a>
+ */
+class ClassicCredentialsPanel extends ClassicPanel implements
PasswordAuthenticationModel
+{
+ //--------------------------------------------------------------
+ // state
+ //--------------------------------------------------------------
+
+ private final JDialog m_parent;
+ private JTextField m_username;
+ private JTextField m_password;
+ private JButton m_ok;
+ private JButton m_revert;
+ private PropertyChangeSupport m_propertyChangeSupport;
+ private PasswordAuthentication m_auth;
+ private PasswordAuthenticationListener m_listener;
+ private boolean m_modified = false;
+
+ //--------------------------------------------------------------
+ // constructor
+ //--------------------------------------------------------------
+
+ /**
+ * Creation of a panel containing the name of an exclude host.
+ *
+ * @param parent the parent dialog
+ */
+ public ClassicCredentialsPanel(
+ JDialog parent, PasswordAuthentication auth,
+ PasswordAuthenticationListener listener ) throws Exception
+ {
+ m_parent = parent;
+ m_auth = auth;
+ m_listener = listener;
+
+ m_propertyChangeSupport = new PropertyChangeSupport( this );
+ m_ok = new JButton( new OKAction( "OK", this ) );
+ m_revert = new JButton( new RevertAction( "Undo" ) );
+
+ // add a text field containing the host url
+
+ {
+ JLabel label =
+ IconHelper.createImageIconJLabel(
+ getClass().getClassLoader(), PASSWORD_IMG_PATH,
+ "Credentials", "Username and password settings." );
+ label.setBorder( new EmptyBorder( 0, 10, 0, 0 ) );
+
+ JPanel rack = new JPanel();
+ rack.setLayout( new BoxLayout( rack, BoxLayout.Y_AXIS ) );
+ rack.setBackground( Color.white );
+ m_username = new JTextField( m_auth.getUserName() );
+ m_username.getDocument().addDocumentListener( new
UsernameDocumentListener() );
+ m_username.setBackground( Color.white );
+ rack.add( new LabelHolder( "Username:" ) );
+ rack.add( m_username );
+
+ m_password = new JPasswordField( new String(
m_auth.getPassword() ) );
+ m_password.getDocument().addDocumentListener( new
PasswordDocumentListener() );
+ m_password.setBackground( Color.white );
+ rack.add( new LabelHolder( "Password:" ) );
+ rack.add( m_password );
+
+ JPanel padding = new JPanel();
+ padding.setBackground( Color.white );
+ padding.setLayout( new BorderLayout() );
+ padding.setBorder( new EmptyBorder( 10, 2, 5, 2) );
+ padding.add( rack, BorderLayout.NORTH );
+
+ getHeader().addStackedEntry( label, "Credentials", padding );
+ }
+
+ // add controls
+
+ {
+ JPanel panel = new JPanel();
+ panel.setLayout( new FlowLayout( FlowLayout.RIGHT ) );
+ panel.add( m_revert );
+ panel.add( m_ok );
+ panel.add( new JButton( new CloseAction( "Close" ) ) );
+ panel.setBorder( new EmptyBorder( 10, 10, 5, 0 ) );
+ panel.setBackground( Color.white );
+ add( panel, BorderLayout.SOUTH );
+ }
+
+ m_propertyChangeSupport.addPropertyChangeListener( new
CredentialsListener() );
+ }
+
+ private class LabelHolder extends JPanel
+ {
+ public LabelHolder( String text )
+ {
+ super( new BorderLayout() );
+ setBackground( Color.white );
+ setBorder( new EmptyBorder( 5, 0, 5, 0 ) );
+ JLabel label = new JLabel( text );
+ label.setBackground( Color.white );
+ add( label, BorderLayout.WEST );
+ }
+ }
+
+ //--------------------------------------------------------------
+ // PasswordAuthenticationModel
+ //--------------------------------------------------------------
+
+ /**
+ * Return the password authentication instance.
+ * @return the authentication credentials
+ */
+ public PasswordAuthentication getAuthentication()
+ {
+ return m_auth;
+ }
+
+ //--------------------------------------------------------------
+ // utilities
+ //--------------------------------------------------------------
+
+ private abstract class AbstractDocumentListener implements
DocumentListener
+ {
+ public void insertUpdate( DocumentEvent event )
+ {
+ fireBaseChangedEvent();
+ }
+
+ public void removeUpdate( DocumentEvent event )
+ {
+ fireBaseChangedEvent();
+ }
+
+ public void changedUpdate( DocumentEvent event )
+ {
+ fireBaseChangedEvent();
+ }
+
+ protected abstract void fireBaseChangedEvent();
+ }
+
+ private class UsernameDocumentListener extends AbstractDocumentListener
+ {
+ protected void fireBaseChangedEvent()
+ {
+ PropertyChangeEvent e =
+ new PropertyChangeEvent(
+ m_username, "username", null, m_username.getText() );
+ m_propertyChangeSupport.firePropertyChange( e );
+ }
+ }
+
+ private class PasswordDocumentListener extends AbstractDocumentListener
+ {
+ protected void fireBaseChangedEvent()
+ {
+ PropertyChangeEvent e =
+ new PropertyChangeEvent(
+ m_password, "password", null, m_password.getText() );
+ m_propertyChangeSupport.firePropertyChange( e );
+ }
+ }
+
+ private class CredentialsListener implements PropertyChangeListener
+ {
+ public void propertyChange( PropertyChangeEvent event )
+ {
+ boolean modified = isModified();
+ m_ok.setEnabled( modified );
+ m_revert.setEnabled( modified );
+ m_modified = modified;
+ }
+
+ private boolean isModified()
+ {
+ if( isPasswordModified() )
+ {
+ return true;
+ }
+ else if( isUsernameModified() )
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ private boolean isPasswordModified()
+ {
+ String password = new String( m_auth.getPassword() );
+ return !m_password.getText().equals( password );
+ }
+
+ private boolean isUsernameModified()
+ {
+ String username = m_auth.getUserName();
+ return !m_username.getText().equals( username );
+ }
+
+ }
+
+ private class CloseAction extends AbstractAction
+ {
+ CloseAction( String name )
+ {
+ super( name );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ m_parent.hide();
+ }
+ }
+
+ private class RevertAction extends AbstractAction
+ {
+ RevertAction( String name )
+ {
+ super( name );
+ setEnabled( false );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ String username = m_auth.getUserName();
+ String old = m_username.getText();
+ m_username.setText( username );
+ PropertyChangeEvent usernameEvent =
+ new PropertyChangeEvent( this, "username", old, username );
+ m_propertyChangeSupport.firePropertyChange( usernameEvent );
+
+ String password = new String( m_auth.getPassword() );
+ m_password.setText( password );
+ PropertyChangeEvent passwordEvent =
+ new PropertyChangeEvent( this, "password", null, null );
+ m_propertyChangeSupport.firePropertyChange( passwordEvent );
+ }
+ }
+
+ private class OKAction extends AbstractAction
+ {
+ private PasswordAuthenticationModel m_model;
+
+ OKAction( String name, PasswordAuthenticationModel model )
+ {
+ super( name );
+ setEnabled( false );
+ m_model = model;
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ if( m_modified )
+ {
+ String username = m_username.getText();
+ String password = m_password.getText();
+ char[] pswd = password.toCharArray();
+ PasswordAuthentication auth = new PasswordAuthentication(
username, pswd );
+ m_auth = auth;
+ try
+ {
+ PasswordAuthenticationEvent e =
+ new PasswordAuthenticationEvent( m_model, auth );
+ m_listener.passwordAuthenticationChanged( e );
+ }
+ catch( Throwable e )
+ {
+ e.printStackTrace();
+ }
+ }
+ m_parent.hide();
+ }
+ }
+
+ //--------------------------------------------------------------
+ // static utils
+ //--------------------------------------------------------------
+
+ private static EmptyBorder border5 = new EmptyBorder( 5, 5, 5, 5);
+ private static String SERVER_IMG_PATH =
"net/dpml/depot/prefs/images/server.png";
+ private static String PASSWORD_IMG_PATH =
"net/dpml/depot/prefs/images/password.png";
+}
+

Added:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ClassicDialog.java
==============================================================================
--- (empty file)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ClassicDialog.java
Mon May 23 16:03:51 2005
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.depot.prefs;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.Window;
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.net.ContentHandler;
+
+import javax.swing.AbstractAction;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.TitledBorder;
+import javax.swing.table.DefaultTableColumnModel;
+import javax.swing.table.TableColumn;
+import javax.swing.table.TableColumnModel;
+
+import net.dpml.transit.Transit;
+import net.dpml.transit.util.ExceptionHelper;
+import net.dpml.transit.content.ContentHandlerRegistry;
+
+/**
+ * Runnable plugin that handles DPML environment setup.
+ *
+ * @author <a href="mailto:mcconnell AT osm.net";>OSM</a>
+ */
+public class ClassicDialog extends JDialog
+{
+ //--------------------------------------------------------------
+ // state
+ //--------------------------------------------------------------
+
+ private JPanel m_body;
+
+ //--------------------------------------------------------------
+ // constructor
+ //--------------------------------------------------------------
+
+ public ClassicDialog( Dialog parent, String title, Dimension size )
+ {
+ super( parent, true );
+ setup( title, size );
+ }
+
+ public ClassicDialog( Frame parent, String title, Dimension size )
+ {
+ super( parent, true );
+ setup( title, size );
+ }
+
+ public JPanel getBody()
+ {
+ return m_body;
+ }
+
+ private void setup( String title, Dimension size )
+ {
+ setTitle( title );
+ m_body = new JPanel();
+ m_body.setLayout( new BorderLayout() );
+ m_body.setBackground( Color.white );
+ m_body.setBorder( new EmptyBorder( 10, 6, 0, 6 ) );
+ setContentPane( m_body );
+ setSize( size );
+ }
+
+ public static ClassicDialog createDialog( Window parent, String title,
Dimension size )
+ {
+ ClassicDialog dialog = null;
+ if( parent instanceof Dialog )
+ {
+ dialog = new ClassicDialog( (Dialog) parent, title, size );
+ }
+ else
+ {
+ dialog = new ClassicDialog( (Frame) parent, title, size );
+ }
+ return dialog;
+ }
+}

Added:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ClassicPanel.java
==============================================================================
--- (empty file)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ClassicPanel.java
Mon May 23 16:03:51 2005
@@ -0,0 +1,246 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.depot.prefs;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.Window;
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.net.ContentHandler;
+import java.util.prefs.Preferences;
+
+import javax.swing.AbstractAction;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.TitledBorder;
+import javax.swing.table.DefaultTableColumnModel;
+import javax.swing.table.TableColumn;
+import javax.swing.table.TableColumnModel;
+
+/**
+ * Runnable plugin that handles DPML environment setup.
+ *
+ * @author <a href="mailto:mcconnell AT osm.net";>OSM</a>
+ */
+class ClassicPanel extends JPanel
+{
+ //--------------------------------------------------------------
+ // static
+ //--------------------------------------------------------------
+
+ static EmptyBorder border5 = new EmptyBorder( 5, 5, 5, 5);
+
+ //--------------------------------------------------------------
+ // state
+ //--------------------------------------------------------------
+
+ private Header m_header;
+ private Body m_body;
+ private JPanel m_footer;
+
+ //--------------------------------------------------------------
+ // constructor
+ //--------------------------------------------------------------
+
+ public ClassicPanel()
+ {
+ super( new BorderLayout() );
+ setBackground( Color.white );
+
+ m_header = new Header();
+ m_header.setLayout( new BoxLayout( m_header, BoxLayout.Y_AXIS ) );
+ m_header.setBorder( new EmptyBorder( 0, 6, 0, 6 ) );
+ m_header.setBackground( Color.white );
+ add( m_header, BorderLayout.NORTH );
+
+ m_body = new Body();
+ add( m_body, BorderLayout.CENTER );
+
+ m_footer = new JPanel();
+ m_footer.setLayout( new FlowLayout( FlowLayout.RIGHT ) );
+ m_footer.setBorder( new EmptyBorder( 10, 10, 5, 0 ) );
+ m_footer.setBackground( Color.white );
+ add( m_footer, BorderLayout.SOUTH );
+ }
+
+ public Header getHeader()
+ {
+ return m_header;
+ }
+
+ public Body getBody()
+ {
+ return m_body;
+ }
+
+ public JPanel getFooter()
+ {
+ return m_footer;
+ }
+
+ public class Header extends JPanel
+ {
+ public Header()
+ {
+ setLayout( new BoxLayout( m_header, BoxLayout.Y_AXIS ) );
+ setBorder( new EmptyBorder( 0, 6, 0, 6 ) );
+ setBackground( Color.white );
+ }
+
+ public void addEntry( JLabel label, String title, Component
component )
+ {
+ JPanel holder = new JPanel();
+ holder.setLayout( new BoxLayout( holder, BoxLayout.Y_AXIS ) );
+ holder.setBorder( new EmptyBorder( 10, 6, 0, 6 ) );
+ holder.setBackground( Color.white );
+
+ JPanel panel = new JPanel();
+ panel.setBackground( Color.white );
+ panel.setLayout( new BorderLayout() );
+ panel.add( label, BorderLayout.WEST );
+ panel.setBorder(
+ new CompoundBorder(
+ new TitledBorder(
+ null, title, TitledBorder.LEFT, TitledBorder.TOP), border5
) );
+
+ if( null != component )
+ {
+ JPanel buttons = new JPanel();
+ buttons.setBackground( Color.white );
+ buttons.setLayout( new BorderLayout() );
+ buttons.add( component, BorderLayout.SOUTH );
+ panel.add( buttons, BorderLayout.EAST );
+ }
+
+ holder.add( panel );
+ add( holder );
+ }
+
+ public void addStackedEntry( JLabel label, String title, Component
component )
+ {
+ JPanel holder = new JPanel();
+ holder.setLayout( new BoxLayout( holder, BoxLayout.Y_AXIS ) );
+ holder.setBorder( new EmptyBorder( 10, 6, 0, 6 ) );
+ holder.setBackground( Color.white );
+
+ JPanel panel = new JPanel();
+ panel.setBackground( Color.white );
+ panel.setLayout( new BorderLayout() );
+ panel.add( label, BorderLayout.WEST );
+ panel.setBorder(
+ new CompoundBorder(
+ new TitledBorder(
+ null, title, TitledBorder.LEFT, TitledBorder.TOP), border5
) );
+
+ if( null != component )
+ {
+ panel.add( component, BorderLayout.SOUTH );
+ }
+
+ holder.add( panel );
+ add( holder );
+ }
+
+ }
+
+ public class Body extends JPanel
+ {
+ public Body()
+ {
+ super( new BorderLayout() );
+ setBackground( Color.white );
+ setBorder( new EmptyBorder( 10, 6, 0, 6 ) );
+ }
+
+ public void addScrollingEntry( Component view, String title,
JButton[] buttons )
+ {
+
+ JPanel panel = new JPanel();
+ panel.setBackground( Color.white );
+ panel.setLayout( new BorderLayout() );
+
+ TitledBorder tb =
+ new TitledBorder(
+ new EmptyBorder( 0,0,0,0 ), title, TitledBorder.LEFT,
TitledBorder.TOP );
+ panel.setBorder( new CompoundBorder( tb, border5 ) );
+
+ JScrollPane scroller = new JScrollPane();
+ scroller.setVerticalScrollBarPolicy(
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED );
+ scroller.setHorizontalScrollBarPolicy(
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ scroller.getViewport().setBackground( Color.white );
+ scroller.setViewportView( view );
+
+ panel.add( scroller );
+
+ JPanel controls = new JPanel();
+ controls.setBorder( new EmptyBorder( 10, 6, 0, 6 ) );
+ controls.setBackground( Color.white );
+ controls.setLayout( new FlowLayout( FlowLayout.RIGHT ) );
+ for( int i=0; i<buttons.length; i++ )
+ {
+ controls.add( buttons[i] );
+ }
+
+ add( panel, BorderLayout.CENTER );
+ add( controls, BorderLayout.SOUTH );
+ }
+ }
+
+ //--------------------------------------------------------------
+ // static
+ //--------------------------------------------------------------
+
+ public static JDialog createDialog( Window parent, String title,
Dimension size, JPanel body )
+ {
+ JDialog dialog = null;
+ if( parent instanceof Dialog )
+ {
+ dialog = new JDialog( (Dialog) parent, true );
+ }
+ else
+ {
+ dialog = new JDialog( (Frame) parent, true );
+ }
+ dialog.setTitle( title );
+ JPanel frame = new JPanel();
+ frame.setLayout( new BorderLayout() );
+ frame.setBackground( Color.white );
+ frame.setBorder( new EmptyBorder( 10, 6, 0, 6 ) );
+ frame.add( body, BorderLayout.CENTER );
+ dialog.setContentPane( frame );
+ dialog.setSize( size );
+ return dialog;
+ }
+}

Copied:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ClassicTable.java
(from r2653,
development/main/depot/prefs/src/main/net/dpml/depot/prefs/GenericTable.java)
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/GenericTable.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ClassicTable.java
Mon May 23 16:03:51 2005
@@ -34,7 +34,7 @@
/**
* A table mapping the collection of preference nodes to hosts.
*/
-public class GenericTable extends JTable implements ListSelectionListener,
FocusListener
+public class ClassicTable extends JTable implements ListSelectionListener,
FocusListener
{

//--------------------------------------------------------------------------
// static
@@ -83,15 +83,16 @@
* @param data a table model containing the data to layout in view
* @param columns the table column model to apply
*/
- public GenericTable( TableModel data, TableColumnModel columns )
+ public ClassicTable( TableModel data, TableColumnModel columns )
{
super( data, columns );

m_data = data;
setShowGrid( false );
setRowHeight( ROW_HEIGHT );
+ setShowVerticalLines( false );
+ setShowHorizontalLines( false );
getTableHeader().setReorderingAllowed( false );
-
MouseListener popupListener = new PopupListener();
addMouseListener( popupListener );
addFocusListener( this );

Modified:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotPreferencesFrame.java
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotPreferencesFrame.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotPreferencesFrame.java
Mon May 23 16:03:51 2005
@@ -39,6 +39,8 @@
import javax.swing.border.EmptyBorder;

import net.dpml.transit.Transit;
+import net.dpml.transit.model.TransitModel;
+import net.dpml.transit.manager.TransitManager;

/**
* Dialog that presents the default preferences for DPML applications
including
@@ -72,7 +74,7 @@
*/
private static final int ZERO = 0;

- public DepotPreferencesFrame() throws Exception
+ public DepotPreferencesFrame( TransitManager manager ) throws Exception
{
super();

@@ -82,7 +84,7 @@
setTitle( "DPML Depot" );
Dimension size = new Dimension( DEFAULT_DIALOG_WIDTH,
DEFAULT_DIALOG_HEIGHT );
setSize( size );
- DepotPreferencesPanel panel = new DepotPreferencesPanel( this );
+ DepotPreferencesPanel panel = new DepotPreferencesPanel( this,
manager );
setContentPane( panel );
getRootPane().setDefaultButton( panel.getDefaultButton() );
addWindowListener(
@@ -97,27 +99,4 @@
setLocation( 300, 200 );
setVisible(true);
}
-
- public static void main( String[] args ) throws Exception
- {
- SwingUtilities.invokeLater(
- new Runnable() {
- public void run()
- {
- setup();
- }
- } );
- }
-
- private static void setup()
- {
- try
- {
- new DepotPreferencesFrame();
- }
- catch( Exception e )
- {
- e.printStackTrace();
- }
- }
}

Modified:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotPreferencesPanel.java
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotPreferencesPanel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotPreferencesPanel.java
Mon May 23 16:03:51 2005
@@ -40,6 +40,8 @@
import javax.swing.border.EmptyBorder;

import net.dpml.transit.Transit;
+import net.dpml.transit.model.TransitModel;
+import net.dpml.transit.manager.TransitManager;

/**
* Panel that presents the default preferences for DPML applications
including
@@ -70,11 +72,14 @@

private ButtonPanel m_buttons;

+ private TransitManager m_manager;

- public DepotPreferencesPanel( Window window ) throws Exception
+ public DepotPreferencesPanel( Window window, TransitManager manager )
throws Exception
{
super( new BorderLayout() );

+ m_manager = manager;
+
JLabel label =
IconHelper.createImageIconJLabel(
getClass().getClassLoader(), DPML_ICON_FILENAME, "", "DPML
Depot" );
@@ -84,17 +89,23 @@
tabbedPane.setBorder( new EmptyBorder( 0, OFFSET, OFFSET, OFFSET ) );

//
- // add the individual application control panels as tabbed panes
+ // add the different management models to the tabbed pane
//

JPanel panel = new JPanel();
+ CacheManagerPanel cachePanel =
+ new CacheManagerPanel( window, manager.getCacheManager() );
+ RegistryManagerPanel registryPanel =
+ new RegistryManagerPanel( window, manager.getRegistryManager() );
+ ProxyManagerPanel proxyPanel =
+ new ProxyManagerPanel( window, manager.getProxyManager() );
+
+ tabbedPane.addTab( "Cache", cachePanel );
+ tabbedPane.addTab( "Content", registryPanel );
+ tabbedPane.addTab( "Proxy", proxyPanel );

- TransitPanel transitPanel = new TransitPanel( window );
- ContentHandlerMainPanel contentPanel = new ContentHandlerMainPanel(
window );
- tabbedPane.addTab( "Transit", transitPanel );
- tabbedPane.addTab( "Content", contentPanel );
- tabbedPane.addTab( "Logging", new JPanel() );
- tabbedPane.addTab( "Profiles", new JPanel() );
+ //tabbedPane.addTab( "Logging", new JPanel() );
+ //tabbedPane.addTab( "Profiles", new JPanel() );

//
// add the Close button
@@ -155,27 +166,4 @@
System.exit(0);
}
}
-
- public static void main( String[] args ) throws Exception
- {
- SwingUtilities.invokeLater(
- new Runnable() {
- public void run()
- {
- setup();
- }
- } );
- }
-
- private static void setup()
- {
- try
- {
- new DepotPreferencesDialog();
- }
- catch( Exception e )
- {
- e.printStackTrace();
- }
- }
}

Copied:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/HostManagerPanel.java
(from r2653,
development/main/depot/prefs/src/main/net/dpml/depot/prefs/TransitResourceHostPanel.java)
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/TransitResourceHostPanel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/HostManagerPanel.java
Mon May 23 16:03:51 2005
@@ -25,10 +25,8 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
+import java.net.URL;
import java.util.Date;
-import java.util.prefs.PreferenceChangeEvent;
-import java.util.prefs.PreferenceChangeListener;
-import java.util.prefs.Preferences;

import javax.swing.AbstractAction;
import javax.swing.BoxLayout;
@@ -46,15 +44,19 @@
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

-import net.dpml.transit.Transit;
-import net.dpml.transit.host.HostDescriptor;
+import net.dpml.transit.manager.HostManager;
+import net.dpml.transit.model.HostListener;
+import net.dpml.transit.model.HostChangeEvent;
+import net.dpml.transit.model.EnabledEvent;
+import net.dpml.transit.model.TrustedEvent;
+import net.dpml.transit.model.PriorityEvent;

/**
* A interactive panel that presents the preferences for a single host.
*
* @author <a href="mailto:mcconnell AT osm.net";>OSM</a>
*/
-class TransitResourceHostPanel extends JPanel implements
PreferenceChangeListener, PropertyChangeListener, DocumentListener
+class HostManagerPanel extends ClassicPanel implements HostListener,
PropertyChangeListener, DocumentListener
{
//--------------------------------------------------------------
// static
@@ -67,46 +69,38 @@
//--------------------------------------------------------------

private final JDialog m_parent;
+ private HostManager m_manager;

private JLabel m_label;
private JCheckBox m_enabled;
private JCheckBox m_trusted;
private JTextField m_base;
-
private JButton m_ok;
private JButton m_revert;

- private Preferences m_hostsPrefs;
- private Preferences m_hostPrefs;
-
private PropertyChangeSupport m_propertyChangeSupport;

//--------------------------------------------------------------
// constructor
//--------------------------------------------------------------

- public TransitResourceHostPanel( JDialog parent, String name ) throws
Exception
+ public HostManagerPanel( JDialog parent, HostManager manager ) throws
Exception
{
m_parent = parent;
- m_propertyChangeSupport = new PropertyChangeSupport( this );
+ m_manager = manager;

- setLayout( new BorderLayout() );
- setBackground( Color.white );
- setBorder( new EmptyBorder( 10, 6, 0, 6 ) );
-
- m_hostsPrefs = Preferences.userNodeForPackage( Transit.class ).node(
"hosts" );
- m_hostPrefs = m_hostsPrefs.node( name );
- m_hostPrefs.addPreferenceChangeListener( this );
+ m_manager.addHostListener( this );
+ m_propertyChangeSupport = new PropertyChangeSupport( this );

- HostDescriptor descriptor = new HostDescriptor( m_hostPrefs );
-
//
// create the dialog label containing the host descriptor name
//

+ String name = manager.getHostName();
m_label =
IconHelper.createImageIconJLabel(
- getClass().getClassLoader(),
"net/dpml/depot/prefs/images/server.png", "Host", "Host: " + name );
+ getClass().getClassLoader(),
+ "net/dpml/depot/prefs/images/server.png", "Host", "Host: " +
name );

m_label.setBorder( new EmptyBorder( 0, 5, 0, 10 ) );
JPanel labelPanel = new JPanel();
@@ -136,7 +130,7 @@
new CompoundBorder(
new TitledBorder( null, "Base URL", TitledBorder.LEFT,
TitledBorder.TOP), border5 ) );

- m_base = new JTextField( descriptor.getBasePath() );
+ m_base = new JTextField( getBasePath() );
m_base.getDocument().addDocumentListener( this ); // listen for
changes
m_base.setBackground( Color.white );
JPanel basePanel = new JPanel();
@@ -160,7 +154,8 @@
//

JPanel layoutPlusCredentials = new JPanel();
- layoutPlusCredentials.setLayout( new BoxLayout(
layoutPlusCredentials, BoxLayout.X_AXIS ) );
+ layoutPlusCredentials.setLayout(
+ new BoxLayout( layoutPlusCredentials, BoxLayout.X_AXIS ) );
layoutPlusCredentials.setBackground( Color.white );
panel.add( layoutPlusCredentials );

@@ -173,7 +168,8 @@
layout.setBackground( Color.white );
layout.setBorder(
new CompoundBorder(
- new TitledBorder( null, "Repository Layout", TitledBorder.LEFT,
TitledBorder.TOP), border5 ) );
+ new TitledBorder( null, "Repository Layout", TitledBorder.LEFT,
TitledBorder.TOP),
+ border5 ) );
layoutPlusCredentials.add( layout );

JComboBox strategy = new JComboBox( new Object[]{ " Classic Layout "
} );
@@ -186,10 +182,13 @@
credentials.setBackground( Color.white );
credentials.setBorder(
new CompoundBorder(
- new TitledBorder( null, "Credentials", TitledBorder.LEFT,
TitledBorder.TOP), border5 ) );
+ new TitledBorder( null, "Credentials", TitledBorder.LEFT,
TitledBorder.TOP),
+ border5 ) );
// TODO: action support for credential settings
ImageIcon keysIcon = IconHelper.createImageIcon(
- getClass().getClassLoader(),
"net/dpml/depot/prefs/images/password.png", "Credentials" );
+ getClass().getClassLoader(),
+ "net/dpml/depot/prefs/images/password.png",
+ "Credentials" );
JLabel keys = new JLabel( keysIcon );
JButton settings = new JButton( "Settings" );
settings.setEnabled( false );
@@ -210,14 +209,15 @@
holder.setBackground( Color.white );
holder.setBorder(
new CompoundBorder(
- new TitledBorder( null, "Parameters", TitledBorder.LEFT,
TitledBorder.TOP), border5 ) );
+ new TitledBorder( null, "Parameters", TitledBorder.LEFT,
TitledBorder.TOP),
+ border5 ) );
panel.add( holder );

// add enabled status

m_enabled = new JCheckBox( new EnableAction( "Enabled" ) );
m_enabled.setBackground( Color.white );
- m_enabled.setSelected( descriptor.getEnabled() );
+ m_enabled.setSelected( m_manager.getEnabled() );

JPanel enabledPanel = new JPanel();
enabledPanel.setLayout( new BorderLayout() );
@@ -230,7 +230,7 @@

m_trusted = new JCheckBox( new TrustedAction( "Trusted" ) );
m_trusted.setBackground( Color.white );
- m_trusted.setSelected( descriptor.getTrusted() );
+ m_trusted.setSelected( m_manager.getTrusted() );

JPanel trustedPanel = new JPanel();
trustedPanel.setLayout( new BorderLayout() );
@@ -266,10 +266,39 @@
}

//--------------------------------------------------------------
- // PreferenceChangeListener
+ // HostListener
//--------------------------------------------------------------

- public void preferenceChange( PreferenceChangeEvent event )
+ /**
+ * Notify a consumer of an aggregated set of changes.
+ * @param event the host change event
+ */
+ public void hostChanged( HostChangeEvent event )
+ {
+
+ }
+
+ /**
+ * Notify a consumer of a change to the enabled state.
+ * @param event the host event
+ */
+ public void enabledStateChanged( EnabledEvent event )
+ {
+ }
+
+ /**
+ * Notify a consumer of a change to the trusted state.
+ * @param event the host event
+ */
+ public void trustedStateChanged( TrustedEvent event )
+ {
+ }
+
+ /**
+ * Notify a consumer of a change to the host priority.
+ * @param event the host event
+ */
+ public void priorityChanged( PriorityEvent event )
{
}

@@ -288,21 +317,21 @@
boolean flag = false;
{
boolean value = m_enabled.isSelected();
- if( m_hostPrefs.getBoolean( "enabled", true ) != value )
+ if( m_manager.getEnabled() != value )
{
flag = true;
}
}
{
boolean value = m_trusted.isSelected();
- if( m_hostPrefs.getBoolean( "trusted", false ) != value )
+ if( m_manager.getTrusted() != value )
{
flag = true;
}
}
{
String path = m_base.getText();
- if( false == path.equals( m_hostPrefs.get( "base", null ) ) )
+ if( false == path.equals( getBasePath()) )
{
flag = true;
}
@@ -332,7 +361,7 @@

private void fireBaseChangedEvent()
{
- String path = m_hostPrefs.get( "base", null );
+ String path = getBasePath();
PropertyChangeEvent e =
new PropertyChangeEvent(
m_base, "base", path, m_base.getText() );
@@ -410,41 +439,44 @@

public void actionPerformed( ActionEvent event )
{
-long now = System.currentTimeMillis();
m_parent.hide();
m_propertyChangeSupport.removePropertyChangeListener( m_listener
);
{
- boolean value = m_enabled.isSelected();
- if( m_hostPrefs.getBoolean( "enabled", true ) != value )
- {
- m_hostPrefs.putBoolean( "enabled", value );
- }
- }
- {
- boolean value = m_trusted.isSelected();
- if( m_hostPrefs.getBoolean( "trusted", true ) != value )
- {
- m_hostPrefs.putBoolean( "trusted", value );
- }
- }
- {
String value = m_base.getText();
- if( false == value.equals( m_hostPrefs.get( "base", null ) )
)
- {
- m_hostPrefs.put( "base", value );
- }
+ URL base = resolveBaseURL( value );
+ m_manager.setBaseURL( base );
}
- try
{
- m_hostPrefs.putLong( "modified", new Date().getTime() ); //
trigger event broadcast
- m_hostPrefs.flush();
+ boolean value = m_trusted.isSelected();
+ m_manager.setTrusted( value );
}
- catch( Throwable e )
{
- e.printStackTrace();
+ boolean value = m_enabled.isSelected();
+ m_manager.setEnabled( value );
}
-long diff = System.currentTimeMillis() - now;
-System.out.println( "# OK: " + diff );
+ //try
+ //{
+ // m_hostPrefs.putLong( "modified", new Date().getTime() );
// trigger event broadcast
+ // m_hostPrefs.flush();
+ //}
+ //catch( Throwable e )
+ //{
+ // e.printStackTrace();
+ //}
+ }
+ }
+
+ private URL resolveBaseURL( String path )
+ {
+ try
+ {
+ return new URL( path );
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Invalid URL value: " + path;
+ throw new RuntimeException( error, e );
}
}

@@ -458,21 +490,26 @@

public void actionPerformed( ActionEvent event )
{
- m_enabled.setSelected( m_hostPrefs.getBoolean( "enabled", true )
);
- m_trusted.setSelected( m_hostPrefs.getBoolean( "trusted", false
) );
- m_base.setText( m_hostPrefs.get( "base", null ) );
- try
- {
- m_hostPrefs.flush();
- }
- catch( Throwable e )
- {
- e.printStackTrace();
- }
+ m_enabled.setSelected( m_manager.getEnabled() );
+ m_trusted.setSelected( m_manager.getTrusted() );
+ m_base.setText( getBasePath() );
PropertyChangeEvent e =
new PropertyChangeEvent(
this, "revert", null, null );
m_propertyChangeSupport.firePropertyChange( e );
}
}
+
+ private String getBasePath()
+ {
+ URL base = m_manager.getBaseURL();
+ if( null == base )
+ {
+ return "";
+ }
+ else
+ {
+ return base.toExternalForm();
+ }
+ }
}

Modified: development/main/depot/prefs/src/main/net/dpml/depot/prefs/Main.java
==============================================================================
--- development/main/depot/prefs/src/main/net/dpml/depot/prefs/Main.java
(original)
+++ development/main/depot/prefs/src/main/net/dpml/depot/prefs/Main.java
Mon May 23 16:03:51 2005
@@ -20,14 +20,14 @@

import java.net.URL;
import java.net.URLClassLoader;
-import java.util.prefs.Preferences;
import java.util.logging.Logger;
import java.util.logging.Level;
+import java.util.prefs.Preferences;

import javax.swing.SwingUtilities;

import net.dpml.transit.Transit;
-
+import net.dpml.transit.manager.TransitManager;

/**
* CLI hander for the depot package.
@@ -97,14 +97,24 @@

private static void setup()
{
+ //
+ // Get the preferences node that will be used as the root node for
+ // the transit manager.
+ //
+
+ Logger logger = Logger.getLogger( "depot.prefs" );
+ Preferences prefs = Preferences.userNodeForPackage( Transit.class );
+ TransitManager manager = null;
+
try
{
- new DepotPreferencesFrame();
+ manager = new TransitManager( logger, prefs );
+ new DepotPreferencesFrame( manager );
}
catch( Exception e )
{
e.printStackTrace();
- }
+ }
}

/**

Added:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/PasswordAuthenticationEvent.java
==============================================================================
--- (empty file)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/PasswordAuthenticationEvent.java
Mon May 23 16:03:51 2005
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2005 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.depot.prefs;
+
+import java.util.EventObject;
+import java.net.PasswordAuthentication;
+
+/**
+ * An event pertaining to a modification to a host model base url,
+ * index, request identifier or connection credentials.
+ */
+public class PasswordAuthenticationEvent extends EventObject
+{
+ private final PasswordAuthentication m_authentication;
+
+ public PasswordAuthenticationEvent( PasswordAuthenticationModel source,
PasswordAuthentication auth )
+ {
+ super( source );
+ m_authentication = auth;
+ }
+
+ public PasswordAuthenticationModel getPasswordAuthenticationModel()
+ {
+ return (PasswordAuthenticationModel) getSource();
+ }
+
+ public PasswordAuthentication getPasswordAuthentication()
+ {
+ return m_authentication;
+ }
+}

Added:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/PasswordAuthenticationListener.java
==============================================================================
--- (empty file)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/PasswordAuthenticationListener.java
Mon May 23 16:03:51 2005
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2005 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.depot.prefs;
+
+import java.util.EventListener;
+
+/**
+ * The PasswordAuthenticationListener is an interface implmented by
+ * objects requiring notification of password changes.
+ */
+public interface PasswordAuthenticationListener extends EventListener
+{
+ /**
+ * Notify a consumer of a change to the password authentication settings.
+ * @param event the password authentication event
+ */
+ void passwordAuthenticationChanged( PasswordAuthenticationEvent event );
+
+}
+

Added:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/PasswordAuthenticationModel.java
==============================================================================
--- (empty file)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/PasswordAuthenticationModel.java
Mon May 23 16:03:51 2005
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2005 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.depot.prefs;
+
+import java.net.Authenticator;
+import java.net.PasswordAuthentication;
+
+/**
+ * The PasswordAuthenticationModel is a interface through which
+ * a PasswordAuthentication instance may be retired.
+ */
+public interface PasswordAuthenticationModel
+{
+ /**
+ * Return the password authentication instance.
+ * @return the authentication credentials
+ */
+ public PasswordAuthentication getAuthentication();
+
+
+}
+

Added:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/PluginManagerPanel.java
==============================================================================
--- (empty file)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/PluginManagerPanel.java
Mon May 23 16:03:51 2005
@@ -0,0 +1,577 @@
+/*
+ * Copyright 2005 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.depot.prefs;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.net.ContentHandler;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import javax.swing.AbstractAction;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.TitledBorder;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+
+import net.dpml.transit.Transit;
+import net.dpml.transit.TransitException;
+import net.dpml.transit.repository.Plugin;
+import net.dpml.transit.repository.Repository;
+import net.dpml.transit.manager.PluginManager;
+import net.dpml.transit.model.PluginListener;
+import net.dpml.transit.model.PluginChangeEvent;
+
+/**
+ * Control panel for editing the cache preferences.
+ *
+ * @author <a href="mailto:mcconnell AT osm.net";>OSM</a>
+ */
+class PluginManagerPanel extends ClassicPanel implements PluginListener,
PropertyChangeListener, DocumentListener
+{
+ //--------------------------------------------------------------
+ // state
+ //--------------------------------------------------------------
+
+ private final JDialog m_parent;
+ private JTextField m_base;
+ private JButton m_ok;
+ private JButton m_revert;
+ private SettingsAction m_settings;
+ private PluginManager m_manager;
+ private PropertyChangeSupport m_propertyChangeSupport;
+
+ //--------------------------------------------------------------
+ // constructor
+ //--------------------------------------------------------------
+
+ /**
+ * Creation of a standard plugin setup panel containing
+ * a user modifiable plugin artifact uri and a controller
+ * parameters button. If a class named [classname]ControlPanel
+ * exists (where [classname] is the plugin classname), the control
+ * panel class will be used to construct a dialog for the selected
+ * plugin. If a class named [classname]Installer exists, the
+ * installer will be instantiated as part of plugin dialog
+ * establishment.
+ *
+ * @param parent the parent dialog
+ * @param prefs the user preferences for the node
net/dpml/transit/content/[type]
+ * @param service the class that a plugin controller must implement
+ */
+ public PluginManagerPanel( JDialog parent, PluginManager manager, Class
service ) throws Exception
+ {
+ super();
+
+ m_parent = parent;
+ m_propertyChangeSupport = new PropertyChangeSupport( this );
+ m_manager = manager;
+
+ m_ok = new JButton( new OKAction( "Install", service ) );
+ m_revert = new JButton( new RevertAction( "Undo" ) );
+ m_manager.addPluginListener( this );
+
+ setLayout( new BorderLayout() );
+ setBackground( Color.white );
+
+ // create a label containing an icon and label
+
+ {
+ JLabel label =
+ IconHelper.createImageIconJLabel(
+ getClass().getClassLoader(), SOURCE_IMG_PATH, "URI", "Plugin
URI" );
+ label.setBorder( new EmptyBorder( 0, 5, 0, 0 ) );
+ JPanel panel = new JPanel();
+ panel.setLayout( new BorderLayout() );
+ panel.setBackground( Color.white );
+ panel.add( label, BorderLayout.WEST );
+ add( panel, BorderLayout.NORTH );
+ }
+
+ // add a test field containing the plugin artifact uri and a
+ // button for optional plugin configuration
+
+ {
+ JPanel holder = new JPanel();
+ holder.setBackground( Color.white );
+ holder.setLayout( new BorderLayout() );
+
+ JPanel panel = new JPanel();
+ panel.setLayout( new BoxLayout( panel, BoxLayout.Y_AXIS ) );
+ panel.setBackground( Color.white );
+ panel.setBorder( new EmptyBorder( 10, 10, 10, 10 ) );
+ {
+ // add the text field
+
+ JPanel padding = new JPanel();
+ padding.setBackground( Color.white );
+ padding.setLayout( new BorderLayout() );
+ padding.setBorder( new EmptyBorder( 10, 2, 5, 2) );
+ String artifact = getControllerFieldText();
+ m_base = new JTextField( artifact );
+ m_base.getDocument().addDocumentListener( this ); // listen
for changes
+ m_base.setBackground( Color.white );
+ padding.add( m_base );
+ panel.add( padding );
+ }
+ {
+ // add the optional controller settings button
+
+ JPanel settingsPanel = new JPanel();
+ settingsPanel.setBorder(
+ new CompoundBorder(
+ new TitledBorder(
+ null, "Controller Settings", TitledBorder.LEFT,
TitledBorder.TOP),
+ new EmptyBorder( 5, 5, 5, 10)
+ )
+ );
+ settingsPanel.setBackground( Color.white );
+ settingsPanel.setLayout( new BorderLayout() );
+ m_settings = new SettingsAction( "Controller Settings",
m_parent );
+ JButton settings = new JButton( m_settings );
+ settingsPanel.add( settings, BorderLayout.EAST );
+ panel.add( settingsPanel );
+ }
+ holder.add( panel, BorderLayout.NORTH );
+ add( holder, BorderLayout.CENTER );
+ }
+
+ // add revert, ok, and cancel
+
+ {
+ JPanel panel = new JPanel();
+ panel.setLayout( new FlowLayout( FlowLayout.RIGHT ) );
+ panel.add( m_revert );
+ panel.add( m_ok );
+ panel.add( new JButton( new CloseAction( "Close" ) ) );
+ panel.setBorder( new EmptyBorder( 10, 10, 5, 0 ) );
+ panel.setBackground( Color.white );
+ add( panel, BorderLayout.SOUTH );
+ }
+
+ m_propertyChangeSupport.addPropertyChangeListener( this );
+ }
+
+ //--------------------------------------------------------------
+ // DocumentListener
+ //--------------------------------------------------------------
+
+ public void insertUpdate( DocumentEvent event )
+ {
+ fireBaseChangedEvent();
+ }
+
+ public void removeUpdate( DocumentEvent event )
+ {
+ fireBaseChangedEvent();
+ }
+
+ public void changedUpdate( DocumentEvent event )
+ {
+ fireBaseChangedEvent();
+ }
+
+ private void fireBaseChangedEvent()
+ {
+ String artifact = getControllerFieldText();
+ PropertyChangeEvent e =
+ new PropertyChangeEvent(
+ m_base, "base", null, m_base.getText() );
+ m_propertyChangeSupport.firePropertyChange( e );
+ }
+
+ //--------------------------------------------------------------
+ // PropertyChangeListener
+ //--------------------------------------------------------------
+
+ /**
+ * The actions dealing with changes to the dialog raise change events
that
+ * are captured here. This listener checks changes and enables or
disabled
+ * the ok and undo buttons based on the state of controls relative to the
+ * underlying preferences for the cache.
+ */
+ public void propertyChange( PropertyChangeEvent event )
+ {
+ String artifact = getControllerFieldText();
+ boolean flag = ( false == artifact.equals( m_base.getText() ) );
+ m_ok.setEnabled( flag );
+ m_revert.setEnabled( flag );
+ if( !flag )
+ {
+ m_settings.setup();
+ }
+ else
+ {
+ m_settings.setEnabled( false );
+ }
+ }
+
+ private String getControllerFieldText()
+ {
+ URI uri = m_manager.getPluginURI();
+ if( null == uri )
+ {
+ return "artifact:plugin:";
+ }
+ else
+ {
+ return uri.toString();
+ }
+ }
+
+ private String getControllerPath()
+ {
+ URI uri = m_manager.getPluginURI();
+ if( null == uri )
+ {
+ return null;
+ }
+ else
+ {
+ return uri.toString();
+ }
+ }
+
+ //--------------------------------------------------------------
+ // PluginListener
+ //--------------------------------------------------------------
+
+ public void pluginChanged( PluginChangeEvent event )
+ {
+ URI uri = event.getPluginURI();
+ String artifact = "";
+ if( uri != null )
+ {
+ artifact = uri.toString();
+ }
+ if( false == m_base.getText().equals( artifact ) )
+ {
+ m_base.setText( artifact );
+ }
+ }
+
+ private class CloseAction extends AbstractAction
+ {
+ CloseAction( String name )
+ {
+ super( name );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ m_parent.hide();
+ }
+ }
+
+ private class SettingsAction extends AbstractAction
+ {
+ private Dialog m_parent;
+ private Dialog m_dialog;
+
+ SettingsAction( String name, Dialog parent )
+ {
+ super( name );
+ m_parent = parent;
+ setup();
+ }
+
+ public void setup()
+ {
+ String controllerPath = getControllerPath();
+ if( null == controllerPath )
+ {
+ setEnabled( false );
+ }
+ else
+ {
+ try
+ {
+ URI uri = new URI( controllerPath );
+ String classname = getControllerClassname( uri );
+ String controlClassname = classname +
CONTROL_PANEL_SUFFIX;
+ ClassLoader classloader = getControllerClassLoader( uri
);
+ m_dialog = createControlPanel( classloader,
controlClassname, m_parent );
+ m_dialog.setModal( true );
+ setEnabled( true );
+ }
+ catch( ClassNotFoundException e )
+ {
+ setEnabled( false );
+ }
+ catch( Throwable e )
+ {
+ System.err.println( e.toString() );
+ e.printStackTrace();
+ setEnabled( false );
+ }
+ }
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ if( m_dialog != null )
+ {
+ m_dialog.setLocationRelativeTo( (Component)
event.getSource() );
+ m_dialog.setVisible( true );
+ }
+ }
+
+ private String getControllerClassname( URI uri ) throws Exception
+ {
+ URL url = new URL( uri.toString() );
+ Plugin plugin = (Plugin) url.getContent( new Class[]{
Plugin.class } );
+ return plugin.getClassname();
+ }
+
+ private ClassLoader getControllerClassLoader( URI uri ) throws
Exception
+ {
+ URL url = new URL( uri.toString() );
+ return (ClassLoader) url.getContent( new Class[]{
ClassLoader.class } );
+ }
+
+ private Dialog createControlPanel( ClassLoader classloader, String
classname, Dialog parent )
+ throws ClassNotFoundException, TransitException
+ {
+ try
+ {
+ Repository repository =
Transit.getInstance().getRepository();
+ Class cls = classloader.loadClass( classname );
+ Object[] args = new Object[]{ parent };
+ return (Dialog) repository.instantiate( cls, args );
+ }
+ catch( ClassNotFoundException e )
+ {
+ throw e;
+ }
+ catch( Throwable e )
+ {
+ String error =
+ "Unable to establish a control panel using the class ["
+ + classname
+ + "].";
+ throw new TransitException( error, e );
+ }
+ }
+ }
+
+ private class RevertAction extends AbstractAction
+ {
+ RevertAction( String name )
+ {
+ super( name );
+ setEnabled( false );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ String artifact = getControllerFieldText();
+ String old = m_base.getText();
+ m_base.setText( artifact );
+ PropertyChangeEvent e =
+ new PropertyChangeEvent( this, "uri", old, artifact );
+ m_propertyChangeSupport.firePropertyChange( e );
+ }
+ }
+
+ private class OKAction extends AbstractAction
+ {
+ private Class m_service;
+
+ OKAction( String name, Class service )
+ {
+ super( name );
+ setEnabled( false );
+ m_service = service;
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ String text = m_base.getText();
+ String artifact = getControllerFieldText();
+ if( false == text.equals( artifact ) )
+ {
+ if( "".equals( text ) )
+ {
+ m_manager.setPluginURI( null );
+ }
+ else
+ {
+ URI uri = validateControllerSpec( m_parent, text,
m_service );
+ if( null != uri )
+ {
+ m_manager.setPluginURI( uri );
+ }
+ }
+ }
+ m_ok.setEnabled( false );
+ m_revert.setEnabled( false );
+ m_settings.setup();
+ }
+ }
+
+ private URI validateControllerSpec( Component component, String spec,
Class service )
+ {
+ URI uri = createControllerURI( component, spec );
+ if( null == uri )
+ {
+ return null;
+ }
+ URL url = getURLFromURI( component, uri );
+ if( null == url )
+ {
+ return null;
+ }
+ Plugin plugin = getPluginFromURL( component, url );
+ if( null == plugin )
+ {
+ return null;
+ }
+ String classname = plugin.getClassname();
+ if( false == checkPluginClass( component, url, service ) )
+ {
+ return null;
+ }
+ return uri;
+ }
+
+ private URI createControllerURI( Component component, String spec )
+ {
+ try
+ {
+ return new URI( spec );
+ }
+ catch( URISyntaxException e )
+ {
+ final String title = "Controller URI Error";
+ final String message = "Invalid uri.";
+ JOptionPane.showMessageDialog( component, message, title,
JOptionPane.ERROR_MESSAGE );
+ return null;
+ }
+ }
+
+ private URL getURLFromURI( Component component, URI uri )
+ {
+ try
+ {
+ String spec = uri.toString();
+ return new URL( spec );
+ }
+ catch( IOException e )
+ {
+ final String title = "Controller URI Error";
+ final String message = "Cannot convert the uri to a url.";
+ JOptionPane.showMessageDialog( component, message, title,
JOptionPane.ERROR_MESSAGE );
+ return null;
+ }
+ }
+
+ private Plugin getPluginFromURL( Component component, URL url )
+ {
+ try
+ {
+ return (Plugin) url.getContent( new Class[]{ Plugin.class } );
+ }
+ catch( Throwable e )
+ {
+ final String title = "Controller URI Error";
+ final String message = e.getMessage();
+ JOptionPane.showMessageDialog( component, message, title,
JOptionPane.ERROR_MESSAGE );
+ return null;
+ }
+ }
+
+ private boolean checkPluginClass( Component component, URL url, Class
service )
+ {
+ Class c = null;
+ try
+ {
+ c = (Class) url.getContent( new Class[]{ Class.class } );
+ }
+ catch( Throwable e )
+ {
+ final String title = "Controller URI Error";
+ final String message = e.getMessage();
+ e.printStackTrace();
+ JOptionPane.showMessageDialog( component, message, title,
JOptionPane.ERROR_MESSAGE );
+ return false;
+ }
+ if( false == service.isAssignableFrom( c ) )
+ {
+ final String title = "Controller URI Error";
+ final String message = "Plugin class does not implement " +
service.getName() + ".";
+ JOptionPane.showMessageDialog( component, message, title,
JOptionPane.ERROR_MESSAGE );
+ System.out.println( c.getClassLoader().toString() );
+ return false;
+ }
+ else
+ {
+ //
+ // check for an installer class
+ //
+
+ String installer = c.getName() + "Installer";
+ try
+ {
+ Class install = c.getClassLoader().loadClass( installer );
+ install.newInstance();
+ return true;
+ }
+ catch( ClassNotFoundException e )
+ {
+ return true;
+ }
+ catch( Throwable e )
+ {
+ final String title = "Controller URI Error";
+ final String message = "Plugin class install error in " +
installer + ".";
+ JOptionPane.showMessageDialog( component, message, title,
JOptionPane.ERROR_MESSAGE );
+ return false;
+ }
+ }
+ }
+
+ //--------------------------------------------------------------
+ // static utils
+ //--------------------------------------------------------------
+
+ private static EmptyBorder border5 = new EmptyBorder( 5, 5, 5, 5);
+
+ private static String SOURCE_IMG_PATH =
"net/dpml/depot/prefs/images/source.png";
+
+ private static final String CONTROL_PANEL_SUFFIX = "ControlPanel";
+}
+

Added:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyExcludeEditPanel.java
==============================================================================
--- (empty file)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyExcludeEditPanel.java
Mon May 23 16:03:51 2005
@@ -0,0 +1,261 @@
+/*
+ * Copyright 2005 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.depot.prefs;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.net.ContentHandler;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import javax.swing.AbstractAction;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.TitledBorder;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+
+import net.dpml.transit.manager.ProxyManager;
+
+/**
+ * Control panel for editing the cache preferences.
+ *
+ * @author <a href="mailto:mcconnell AT osm.net";>OSM</a>
+ */
+class ProxyExcludeEditPanel extends JPanel implements
PropertyChangeListener, DocumentListener
+{
+ //--------------------------------------------------------------
+ // state
+ //--------------------------------------------------------------
+
+ private final JDialog m_parent;
+ private JTextField m_base;
+ private JButton m_ok;
+ private JButton m_revert;
+ private PropertyChangeSupport m_propertyChangeSupport;
+ private ProxyManager m_manager;
+ private String m_key;
+
+ //--------------------------------------------------------------
+ // constructor
+ //--------------------------------------------------------------
+
+ /**
+ * Creation of a panel containing the name of an exclude host.
+ *
+ * @param parent the parent dialog
+ */
+ public ProxyExcludeEditPanel( JDialog parent, ProxyManager manager,
String key ) throws Exception
+ {
+ m_parent = parent;
+ m_propertyChangeSupport = new PropertyChangeSupport( this );
+ m_manager = manager;
+
+ m_ok = new JButton( new OKAction( "OK" ) );
+ m_revert = new JButton( new RevertAction( "Undo" ) );
+
+ setLayout( new BorderLayout() );
+ setBackground( Color.white );
+
+ // create a label containing an icon and label
+
+ {
+ JLabel label =
+ IconHelper.createImageIconJLabel(
+ getClass().getClassLoader(), SERVER_IMG_PATH, "Host", "Host
URL" );
+ label.setBorder( new EmptyBorder( 0, 5, 0, 0 ) );
+ JPanel panel = new JPanel();
+ panel.setLayout( new BorderLayout() );
+ panel.setBackground( Color.white );
+ panel.add( label, BorderLayout.WEST );
+ add( panel, BorderLayout.NORTH );
+ }
+
+ // add a test field containing the host url
+
+ {
+ JPanel holder = new JPanel();
+ holder.setBackground( Color.white );
+ holder.setLayout( new BorderLayout() );
+
+ JPanel panel = new JPanel();
+ panel.setLayout( new BoxLayout( panel, BoxLayout.Y_AXIS ) );
+ panel.setBackground( Color.white );
+ panel.setBorder( new EmptyBorder( 10, 10, 10, 10 ) );
+ {
+ // add the text field
+
+ JPanel padding = new JPanel();
+ padding.setBackground( Color.white );
+ padding.setLayout( new BorderLayout() );
+ padding.setBorder( new EmptyBorder( 10, 2, 5, 2) );
+ m_base = new JTextField( key );
+ m_base.getDocument().addDocumentListener( this ); // listen
for changes
+ m_base.setBackground( Color.white );
+ padding.add( m_base );
+ panel.add( padding );
+ }
+ holder.add( panel, BorderLayout.NORTH );
+ add( holder, BorderLayout.CENTER );
+ }
+
+ // add revert, ok, and cancel
+
+ {
+ JPanel panel = new JPanel();
+ panel.setLayout( new FlowLayout( FlowLayout.RIGHT ) );
+ panel.add( m_revert );
+ panel.add( m_ok );
+ panel.add( new JButton( new CloseAction( "Close" ) ) );
+ panel.setBorder( new EmptyBorder( 10, 10, 5, 0 ) );
+ panel.setBackground( Color.white );
+ add( panel, BorderLayout.SOUTH );
+ }
+
+ m_propertyChangeSupport.addPropertyChangeListener( this );
+ }
+
+ //--------------------------------------------------------------
+ // DocumentListener
+ //--------------------------------------------------------------
+
+ public void insertUpdate( DocumentEvent event )
+ {
+ fireBaseChangedEvent();
+ }
+
+ public void removeUpdate( DocumentEvent event )
+ {
+ fireBaseChangedEvent();
+ }
+
+ public void changedUpdate( DocumentEvent event )
+ {
+ fireBaseChangedEvent();
+ }
+
+ private void fireBaseChangedEvent()
+ {
+ PropertyChangeEvent e =
+ new PropertyChangeEvent(
+ m_base, "base", null, m_base.getText() );
+ m_propertyChangeSupport.firePropertyChange( e );
+ }
+
+ //--------------------------------------------------------------
+ // PropertyChangeListener
+ //--------------------------------------------------------------
+
+ /**
+ * The actions dealing with changes to the dialog raise change events
that
+ * are captured here. This listener checks changes and enables or
disabled
+ * the ok and undo buttons based on the state of controls relative to the
+ * underlying preferences for the cache.
+ */
+ public void propertyChange( PropertyChangeEvent event )
+ {
+ boolean flag = ( false == m_key.equals( m_base.getText() ) );
+ m_ok.setEnabled( flag );
+ m_revert.setEnabled( flag );
+ }
+
+ private class CloseAction extends AbstractAction
+ {
+ CloseAction( String name )
+ {
+ super( name );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ m_parent.hide();
+ }
+ }
+
+ private class RevertAction extends AbstractAction
+ {
+ RevertAction( String name )
+ {
+ super( name );
+ setEnabled( false );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ String old = m_base.getText();
+ m_base.setText( m_key );
+ PropertyChangeEvent e =
+ new PropertyChangeEvent( this, "uri", old, m_key );
+ m_propertyChangeSupport.firePropertyChange( e );
+ }
+ }
+
+ private class OKAction extends AbstractAction
+ {
+ OKAction( String name )
+ {
+ super( name );
+ setEnabled( false );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ String text = m_base.getText();
+ if( false == text.equals( m_key ) )
+ {
+ if( "".equals( text ) )
+ {
+ m_manager.removeExclude( m_key );
+ }
+ else
+ {
+ m_manager.changeExclude( m_key, text );
+ }
+ }
+ m_ok.setEnabled( false );
+ m_revert.setEnabled( false );
+ }
+ }
+
+ //--------------------------------------------------------------
+ // static utils
+ //--------------------------------------------------------------
+
+ private static EmptyBorder border5 = new EmptyBorder( 5, 5, 5, 5);
+
+ private static String SERVER_IMG_PATH =
"net/dpml/depot/prefs/images/server.png";
+}
+

Added:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyExcludesTableModel.java
==============================================================================
--- (empty file)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyExcludesTableModel.java
Mon May 23 16:03:51 2005
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2005 Stephen McConnell
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.depot.prefs;
+
+import javax.swing.Icon;
+import javax.swing.table.AbstractTableModel;
+
+import net.dpml.transit.Transit;
+import net.dpml.transit.model.ProxyListener;
+import net.dpml.transit.model.ProxyModel;
+import net.dpml.transit.model.ProxyChangeEvent;
+import net.dpml.transit.model.ProxyExcludesEvent;
+
+/**
+ * Table model that presents the set of excluded hosts.
+ */
+public class ProxyExcludesTableModel extends AbstractTableModel implements
ProxyListener
+{
+
//--------------------------------------------------------------------------
+ // state
+
//--------------------------------------------------------------------------
+
+ ProxyModel m_model;
+
+
//--------------------------------------------------------------------------
+ // constructor
+
//--------------------------------------------------------------------------
+
+ public ProxyExcludesTableModel( ProxyModel model )
+ {
+ super();
+ m_model = model;
+ model.addProxyListener( this );
+ }
+
+ protected void finalize()
+ {
+ m_model.removeProxyListener( this );
+ }
+
+
//--------------------------------------------------------------------------
+ // ProxyListener
+
//--------------------------------------------------------------------------
+
+ /**
+ * Notify a listener of the change to Transit proxy settings.
+ * @param event the proxy change event
+ */
+ public void proxySettingsChanged( ProxyChangeEvent event )
+ {
+ // not our problem
+ }
+
+ /**
+ * Notify a listener of the change to the set of excluded hosts.
+ * @param event the proxy excludes change event
+ */
+ public void proxyExcludesChanged( ProxyExcludesEvent event )
+ {
+ fireTableStructureChanged();
+ }
+
+
//--------------------------------------------------------------------------
+ // NodeTableModel
+
//--------------------------------------------------------------------------
+
+ /**
+ * Returns the number of model columns.
+ * @return int the number of columns maintained by the model
+ */
+ public int getColumnCount()
+ {
+ return 1;
+ }
+
+ /**
+ * Returns the number of rows in the model. The value returned is
+ * equivilent to the number of elements in the list backing the model.
+ * @return int the number of rows maintained by the model
+ */
+ public int getRowCount()
+ {
+ try
+ {
+ return m_model.getExcludes().length;
+ }
+ catch( Throwable e )
+ {
+ return 0;
+ }
+ }
+
+ /**
+ * Returns the feature object at the request column and row combination.
+ * If the col index is out of range the method returns the agent
corresponding
+ * to the row identifier.
+ * @param row the row index
+ * @param col the column index
+ * @return Object
+ */
+ public Object getValueAt( int row, int col )
+ {
+ String[] excludes = m_model.getExcludes();
+ try
+ {
+ return excludes[ row ];
+ }
+ catch( Throwable e )
+ {
+ return null;
+ }
+ }
+}

Added:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyFeaturesPanel.java
==============================================================================
--- (empty file)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyFeaturesPanel.java
Mon May 23 16:03:51 2005
@@ -0,0 +1,358 @@
+/*
+ * Copyright 2005 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.depot.prefs;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.net.ContentHandler;
+import java.net.URI;
+import java.net.PasswordAuthentication;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.logging.Logger;
+import java.util.logging.Level;
+
+import javax.swing.AbstractAction;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.ImageIcon;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.TitledBorder;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+
+import net.dpml.transit.manager.ProxyManager;
+
+/**
+ * Control panel for editing the cache preferences.
+ *
+ * @author <a href="mailto:mcconnell AT osm.net";>OSM</a>
+ */
+class ProxyFeaturesPanel extends ClassicPanel implements
PropertyChangeListener, DocumentListener
+{
+ //--------------------------------------------------------------
+ // state
+ //--------------------------------------------------------------
+
+ private final JDialog m_parent;
+ private JTextField m_base;
+ private JButton m_ok;
+ private JButton m_revert;
+ private PropertyChangeSupport m_propertyChangeSupport;
+ private ProxyManager m_manager;
+ private String m_host;
+ private CredentialsAction m_credentials;
+ private JButton m_close;
+
+ //--------------------------------------------------------------
+ // constructor
+ //--------------------------------------------------------------
+
+ /**
+ * Creation of a panel containing the name of an exclude host.
+ *
+ * @param parent the parent dialog
+ */
+ public ProxyFeaturesPanel( JDialog parent, ProxyManager manager ) throws
Exception
+ {
+ m_parent = parent;
+ m_manager = manager;
+
+ m_host = getProxyHost();
+ m_propertyChangeSupport = new PropertyChangeSupport( this );
+ m_ok = new JButton( new OKAction( "OK" ) );
+ m_revert = new JButton( new RevertAction( "Undo" ) );
+ m_credentials = new CredentialsAction( "Credentials" );
+ m_credentials.setEnabled( false == "".equals( m_host ) );
+ m_close = new JButton( new CloseAction( "Close" ) );
+
+ // add a text field containing the host url
+
+ {
+ JLabel label =
+ IconHelper.createImageIconJLabel(
+ getClass().getClassLoader(), SERVER_IMG_PATH,
+ "Proxy", "Proxy server hostname" );
+
+ label.setBorder( new EmptyBorder( 0, 5, 0, 0 ) );
+ JPanel padding = new JPanel();
+ padding.setBackground( Color.white );
+ padding.setLayout( new BorderLayout() );
+ padding.setBorder( new EmptyBorder( 10, 2, 5, 2) );
+ m_base = new JTextField( m_host );
+ m_base.getDocument().addDocumentListener( this ); // listen for
changes
+ m_base.setBackground( Color.white );
+ padding.add( m_base );
+
+ getHeader().addStackedEntry( label, "Proxy Server", padding );
+ }
+
+ // add a text field containing the username and password
+
+ {
+ JLabel label =
+ IconHelper.createImageIconJLabel(
+ getClass().getClassLoader(), PASSWORD_IMG_PATH,
+ "Credentials", "Sign-on credentials" );
+ label.setBorder( new EmptyBorder( 0, 10, 0, 0 ) );
+ JButton credentials = new JButton( m_credentials );
+ getHeader().addEntry( label, "Proxy Server Sign-on Credentials",
credentials );
+ }
+
+ // add revert, ok, and cancel
+
+ {
+ JPanel panel = new JPanel();
+ panel.setLayout( new FlowLayout( FlowLayout.RIGHT ) );
+ panel.add( m_revert );
+ panel.add( m_ok );
+ panel.add( m_close );
+ panel.setBorder( new EmptyBorder( 10, 10, 5, 0 ) );
+ panel.setBackground( Color.white );
+ add( panel, BorderLayout.SOUTH );
+ }
+
+ m_propertyChangeSupport.addPropertyChangeListener( this );
+ }
+
+ //--------------------------------------------------------------
+ // DocumentListener
+ //--------------------------------------------------------------
+
+ public void insertUpdate( DocumentEvent event )
+ {
+ fireBaseChangedEvent();
+ }
+
+ public void removeUpdate( DocumentEvent event )
+ {
+ fireBaseChangedEvent();
+ }
+
+ public void changedUpdate( DocumentEvent event )
+ {
+ fireBaseChangedEvent();
+ }
+
+ private void fireBaseChangedEvent()
+ {
+ PropertyChangeEvent e =
+ new PropertyChangeEvent(
+ m_base, "base", null, m_base.getText() );
+ m_propertyChangeSupport.firePropertyChange( e );
+ }
+
+ //--------------------------------------------------------------
+ // PropertyChangeListener
+ //--------------------------------------------------------------
+
+ /**
+ * The actions dealing with changes to the dialog raise change events
that
+ * are captured here. This listener checks changes and enables or
disabled
+ * the ok and undo buttons based on the state of controls relative to the
+ * underlying preferences for the cache.
+ */
+ public void propertyChange( PropertyChangeEvent event )
+ {
+ String base = m_base.getText();
+ boolean flag = ( false == m_host.equals( base ) );
+ m_ok.setEnabled( flag );
+ m_revert.setEnabled( flag );
+ m_credentials.setEnabled( false == "".equals( base ) );
+ if( flag )
+ {
+ getRootPane().setDefaultButton( m_ok );
+ }
+ else
+ {
+ getRootPane().setDefaultButton( m_close );
+ }
+ }
+
+ public JButton getDefaultButton()
+ {
+ String base = m_base.getText();
+ boolean flag = ( false == m_host.equals( base ) );
+ if( flag )
+ {
+ return m_ok;
+ }
+ else
+ {
+ return m_close;
+ }
+ }
+
+ //--------------------------------------------------------------
+ // utilities
+ //--------------------------------------------------------------
+
+ private class CloseAction extends AbstractAction
+ {
+ CloseAction( String name )
+ {
+ super( name );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ m_parent.hide();
+ }
+ }
+
+ private class RevertAction extends AbstractAction
+ {
+ RevertAction( String name )
+ {
+ super( name );
+ setEnabled( false );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ String old = m_base.getText();
+ m_base.setText( m_host );
+ PropertyChangeEvent e =
+ new PropertyChangeEvent( this, "uri", old, m_host );
+ m_propertyChangeSupport.firePropertyChange( e );
+ }
+ }
+
+ private class OKAction extends AbstractAction
+ {
+ OKAction( String name )
+ {
+ super( name );
+ setEnabled( false );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ String text = m_base.getText();
+ if( false == text.equals( m_host ) )
+ {
+ if( "".equals( text ) )
+ {
+ m_manager.setProxyHost( null );
+ }
+ else
+ {
+ m_manager.setProxyHost( text );
+ }
+ }
+ m_ok.setEnabled( false );
+ m_revert.setEnabled( false );
+ m_parent.hide();
+ }
+ }
+
+ private class CredentialsAction extends AbstractAction implements
PasswordAuthenticationListener
+ {
+ CredentialsAction( String name )
+ {
+ super( name );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ try
+ {
+ final String title = "Proxy Credentials";
+ final Dimension size = new Dimension( 300, 280 );
+ ClassicDialog dialog = ClassicDialog.createDialog( m_parent,
title, size );
+ PasswordAuthentication auth =
m_manager.getProxyAuthentication();
+ ClassicCredentialsPanel panel =
+ new ClassicCredentialsPanel( dialog, auth, this );
+ dialog.getBody().add( panel );
+ dialog.setLocationRelativeTo( (Component) event.getSource()
);
+ dialog.setResizable( false );
+ dialog.setVisible(true);
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to handle the
'Controller' action. "
+ + "\nCODEBASE: "
+ +
getClass().getProtectionDomain().getCodeSource().getLocation().toString();
+ Logger logger = Logger.getLogger( "depot.prefs" );
+ logger.log( Level.SEVERE, error, e );
+ }
+ }
+
+ /**
+ * Notify a consumer of a change to the host priority.
+ * @param event the host event
+ */
+ public void passwordAuthenticationChanged(
PasswordAuthenticationEvent event )
+ {
+ PasswordAuthentication auth = event.getPasswordAuthentication();
+ try
+ {
+ m_manager.setProxyAuthentication( auth );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to update proxy sign-on
credentials. "
+ + "\nCODEBASE: "
+ +
getClass().getProtectionDomain().getCodeSource().getLocation().toString();
+ Logger logger = Logger.getLogger( "depot.prefs" );
+ logger.log( Level.SEVERE, error, e );
+ }
+ }
+ }
+
+ private String getProxyHost()
+ {
+ String host = m_manager.getProxyHost();
+ if( null == host )
+ {
+ return "";
+ }
+ else
+ {
+ return host;
+ }
+ }
+
+ //--------------------------------------------------------------
+ // static utils
+ //--------------------------------------------------------------
+
+ private static EmptyBorder border5 = new EmptyBorder( 5, 5, 5, 5);
+ private static String SERVER_IMG_PATH =
"net/dpml/depot/prefs/images/server.png";
+ private static String PASSWORD_IMG_PATH =
"net/dpml/depot/prefs/images/password.png";
+}
+

Added:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyManagerPanel.java
==============================================================================
--- (empty file)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ProxyManagerPanel.java
Mon May 23 16:03:51 2005
@@ -0,0 +1,264 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.depot.prefs;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.Window;
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.net.ContentHandler;
+import java.util.logging.Logger;
+import java.util.logging.Level;
+
+import javax.swing.AbstractAction;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.TitledBorder;
+import javax.swing.table.DefaultTableColumnModel;
+import javax.swing.table.TableColumn;
+import javax.swing.table.TableColumnModel;
+
+import net.dpml.transit.Transit;
+import net.dpml.transit.util.ExceptionHelper;
+import net.dpml.transit.model.ProxyModel;
+import net.dpml.transit.manager.ProxyManager;
+
+/**
+ * Runnable plugin that handles DPML environment setup.
+ *
+ * @author <a href="mailto:mcconnell AT osm.net";>OSM</a>
+ */
+class ProxyManagerPanel extends ClassicPanel implements
PropertyChangeListener
+{
+ //--------------------------------------------------------------
+ // static
+ //--------------------------------------------------------------
+
+ static EmptyBorder border5 = new EmptyBorder( 5, 5, 5, 5);
+
+ //--------------------------------------------------------------
+ // state
+ //--------------------------------------------------------------
+
+ private final Window m_parent;
+ private ProxyManager m_manager;
+ private AddAction m_add;
+ private EditAction m_edit;
+ private JButton m_editButton;
+ private RemoveAction m_remove;
+ private SettingsAction m_settings;
+ private String m_selection;
+
+ //--------------------------------------------------------------
+ // constructor
+ //--------------------------------------------------------------
+
+ public ProxyManagerPanel( Window parent, ProxyManager manager) throws
Exception
+ {
+ super();
+
+ m_parent = parent;
+ m_manager = manager;
+
+ //
+ // setup info about the proxy host, scheme and prompt
+ //
+
+ JLabel label =
+ IconHelper.createImageIconJLabel(
+ getClass().getClassLoader(), SERVER_IMG_PATH,
+ "Proxy", "Proxy server properties and settings." );
+ label.setBorder( new EmptyBorder( 0, 5, 0, 0 ) );
+ m_settings = new SettingsAction( "Settings" );
+ getHeader().addEntry( label, "Proxy Server", new JButton( m_settings
) );
+
+ // create a table containing the excludes
+
+ m_add = new AddAction( "Add" );
+ m_edit = new EditAction( "Edit" );
+ m_remove = new RemoveAction( "Remove" );
+ m_editButton = new JButton( m_edit );
+
+ TableColumnModel columns = new DefaultTableColumnModel();
+ columns.addColumn( new TableColumn( 0, 100, new
ClassicCellRenderer(), null ) );
+ ProxyExcludesTableModel tableModel = new ProxyExcludesTableModel(
manager );
+ ClassicTable table = new ClassicTable( tableModel, columns );
+ table.addPropertyChangeListener( this );
+ JButton[] buttons = new JButton[ 3 ];
+ buttons[0] = new JButton( m_add );
+ buttons[1] = m_editButton;
+ buttons[2] = new JButton( m_remove );
+ getBody().addScrollingEntry( table, "Excluded hosts", buttons );
+ }
+
+ //--------------------------------------------------------------
+ // PropertyChangelistener
+ //--------------------------------------------------------------
+
+ /**
+ * Handle property change events raised by the table model.
+ */
+ public void propertyChange( PropertyChangeEvent event )
+ {
+ if( "selection".equals( event.getPropertyName() ) )
+ {
+ m_selection = (String) event.getNewValue();
+ if( null != m_selection )
+ {
+ m_edit.setEnabled( true );
+ m_remove.setEnabled( true );
+ getRootPane().setDefaultButton( m_editButton );
+ }
+ else
+ {
+ m_edit.setEnabled( false );
+ m_remove.setEnabled( false );
+ }
+ }
+ else if( "doubleclick".equals( event.getPropertyName() ) )
+ {
+ m_edit.edit();
+ }
+ }
+
+ //--------------------------------------------------------------
+ // internals
+ //--------------------------------------------------------------
+
+ private class RemoveAction extends AbstractAction
+ {
+ public RemoveAction( String name )
+ {
+ super( name );
+ setEnabled( true );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ if( m_selection != null )
+ {
+ m_manager.removeExclude( m_selection );
+ }
+ }
+ }
+
+ private class EditAction extends AbstractAction
+ {
+ public EditAction( String name )
+ {
+ super( name );
+ setEnabled( true );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ edit();
+ }
+
+ public void edit()
+ {
+ String name = JOptionPane.showInputDialog( m_parent, "Host:",
m_selection );
+ if( null == name )
+ {
+ return;
+ }
+ else
+ {
+ m_manager.changeExclude( m_selection, name );
+ }
+ }
+ }
+
+ private class AddAction extends AbstractAction
+ {
+ public AddAction( String name )
+ {
+ super( name );
+ setEnabled( true );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ String name = JOptionPane.showInputDialog( m_parent, "Host:" );
+ if( null == name )
+ {
+ return;
+ }
+ else
+ {
+ m_manager.addExclude( name );
+ }
+ }
+ }
+
+ private class SettingsAction extends AbstractAction
+ {
+ public SettingsAction( String name )
+ {
+ super( name );
+ setEnabled( true );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ try
+ {
+ final String title = "Proxy Host Settings";
+ final Dimension size = new Dimension( 400, 280 );
+ ClassicDialog dialog = ClassicDialog.createDialog( m_parent,
title, size );
+ ProxyFeaturesPanel panel = new ProxyFeaturesPanel( dialog,
m_manager );
+ dialog.getBody().add( panel );
+ dialog.setLocationRelativeTo( (Component) event.getSource()
);
+ dialog.getRootPane().setDefaultButton(
panel.getDefaultButton() );
+ dialog.setResizable( false );
+ dialog.setVisible(true);
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to handle the 'Proxy
Settings' action. "
+ + "\nCODEBASE: "
+ +
getClass().getProtectionDomain().getCodeSource().getLocation().toString();
+ Logger logger = Logger.getLogger( "depot.prefs" );
+ logger.log( Level.SEVERE, error, e );
+ }
+ }
+ }
+
+ //--------------------------------------------------------------
+ // static (utils)
+ //--------------------------------------------------------------
+
+ private static String SERVER_IMG_PATH =
"net/dpml/depot/prefs/images/server.png";
+
+}

Added:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/RegistryManagerPanel.java
==============================================================================
--- (empty file)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/RegistryManagerPanel.java
Mon May 23 16:03:51 2005
@@ -0,0 +1,361 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.depot.prefs;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.Window;
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.net.ContentHandler;
+import java.util.logging.Logger;
+import java.util.logging.Level;
+
+import javax.swing.AbstractAction;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.TitledBorder;
+import javax.swing.table.DefaultTableColumnModel;
+import javax.swing.table.TableColumn;
+import javax.swing.table.TableColumnModel;
+
+import net.dpml.transit.Transit;
+import net.dpml.transit.util.ExceptionHelper;
+import net.dpml.transit.content.ContentHandlerRegistry;
+import net.dpml.transit.manager.RegistryManager;
+import net.dpml.transit.manager.ContentManager;
+
+/**
+ * Runnable plugin that handles DPML environment setup.
+ *
+ * @author <a href="mailto:mcconnell AT osm.net";>OSM</a>
+ */
+class RegistryManagerPanel extends ClassicPanel implements
PropertyChangeListener
+{
+ //--------------------------------------------------------------
+ // state
+ //--------------------------------------------------------------
+
+ private final Window m_parent;
+ private ClassicTable m_table;
+ private EditAction m_editAction;
+ private JButton m_edit;
+ private JButton m_delete;
+ private String m_selection;
+
+ private RegistryManager m_manager;
+
+ //--------------------------------------------------------------
+ // constructor
+ //--------------------------------------------------------------
+
+ public RegistryManagerPanel( Window parent, RegistryManager manager )
throws Exception
+ {
+ super();
+
+ m_manager = manager;
+ m_parent = parent;
+
+ m_editAction = new EditAction( "Edit" );
+ m_edit = new JButton( m_editAction );
+ m_delete = new JButton( new DeleteAction( "Delete" ) );
+
+ JPanel panel = new JPanel();
+ panel.setBackground( Color.white );
+ panel.setLayout( new BorderLayout() );
+ TitledBorder tb =
+ new TitledBorder(
+ new EmptyBorder( 0,0,0,0 ), "Content Handlers",
TitledBorder.LEFT, TitledBorder.TOP );
+ panel.setBorder( new CompoundBorder( tb, border5 ) );
+
+ TableColumnModel columns = createContentHandlerColumnModel();
+ RegistryTableModel model = new RegistryTableModel( manager );
+
+ m_table = new ClassicTable( model, columns );
+ m_table.addPropertyChangeListener( this );
+ m_table.setShowVerticalLines( false );
+ m_table.setShowHorizontalLines( false );
+
+ JScrollPane scroller = createScrollPanel( m_table );
+ panel.add( scroller, BorderLayout.CENTER );
+ JPanel buttons = new JPanel();
+ buttons.setLayout( new FlowLayout( FlowLayout.RIGHT ) );
+ buttons.add( new JButton( new AddAction( "Add" ) ) );
+ buttons.add( m_edit );
+ buttons.add( m_delete );
+ buttons.setBorder( new EmptyBorder( 10, 10, 5, 0 ) );
+ buttons.setBackground( Color.white );
+ panel.add( buttons, BorderLayout.SOUTH );
+
+ JLabel label =
+ IconHelper.createImageIconJLabel(
+ getClass().getClassLoader(), MISC_IMG_PATH,
+ "Artifact", "Content Handler Controller settings." );
+ label.setBorder( new EmptyBorder( 0, 5, 0, 0 ) );
+ ControllerAction controller = new ControllerAction( "Controller" );
+ getHeader().addEntry( label, "Proxy Server", new JButton( controller
) );
+
+ //add( controllerPanel, BorderLayout.NORTH );
+ getBody().add( panel );
+ }
+
+ //--------------------------------------------------------------
+ // PropertyChangelistener
+ //--------------------------------------------------------------
+
+ /**
+ * handle property change events raised by the table model.
+ */
+ public void propertyChange( PropertyChangeEvent event )
+ {
+ if( "selection".equals( event.getPropertyName() ) )
+ {
+ m_selection = (String) event.getNewValue();
+ if( null != m_selection )
+ {
+ m_edit.setEnabled( true );
+ m_delete.setEnabled( true );
+ getRootPane().setDefaultButton( m_edit );
+ }
+ else
+ {
+ m_edit.setEnabled( false );
+ m_delete.setEnabled( false );
+ }
+ }
+ else if( "doubleclick".equals( event.getPropertyName() ) )
+ {
+ m_editAction.editSelection( m_edit );
+ }
+ }
+
+ //--------------------------------------------------------------
+ // utilities
+ //--------------------------------------------------------------
+
+ private JPanel createContentHandlerControllerPanel( Window parent )
+ {
+ JLabel label =
+ IconHelper.createImageIconJLabel(
+ getClass().getClassLoader(),
+ "net/dpml/depot/prefs/images/misc.png",
+ "Artifact",
+ "Content Handler Controller settings." );
+ label.setBorder( new EmptyBorder( 0, 5, 0, 0 ) );
+
+ JPanel holder = new JPanel();
+ holder.setLayout( new BoxLayout( holder, BoxLayout.Y_AXIS ) );
+ holder.setBorder( new EmptyBorder( 0, 6, 0, 6 ) );
+ holder.setBackground( Color.white );
+
+ JPanel panel = new JPanel();
+ panel.setBackground( Color.white );
+ panel.setLayout( new BorderLayout() );
+ panel.add( label, BorderLayout.WEST );
+ panel.setBorder(
+ new CompoundBorder(
+ new TitledBorder( null, "Controller", TitledBorder.LEFT,
TitledBorder.TOP), border5 ) );
+ JButton button = new JButton( new ControllerAction( "Controller" ) );
+ JPanel buttons = new JPanel();
+ buttons.setBackground( Color.white );
+ buttons.setLayout( new BorderLayout() );
+ buttons.add( button, BorderLayout.SOUTH );
+ panel.add( buttons, BorderLayout.EAST );
+ holder.add( panel );
+ return holder;
+ }
+
+ private class ControllerAction extends AbstractAction
+ {
+ ControllerAction( String name )
+ {
+ super( name );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ try
+ {
+ final String title = "Content Handler Controller";
+ final Dimension size = new Dimension( 400, 240 );
+ ClassicDialog dialog = ClassicDialog.createDialog( m_parent,
title, size );
+ PluginManagerPanel panel =
+ new PluginManagerPanel( dialog, m_manager,
ContentHandlerRegistry.class );
+ dialog.getBody().add( panel );
+ dialog.setLocationRelativeTo( (Component) event.getSource()
);
+ dialog.setResizable( false );
+ dialog.setVisible(true);
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to handle the
'Controller' action. "
+ + "\nCODEBASE: "
+ +
getClass().getProtectionDomain().getCodeSource().getLocation().toString();
+ String message = ExceptionHelper.packException( error, e,
true );
+ System.err.println( message );
+ }
+ }
+ }
+
+ /**
+ * Creation of a parameterized scroll pane.
+ * @param view the viewport view
+ * @return the scroll pane wrapping the supplied view
+ */
+ private static JScrollPane createScrollPanel( Component view )
+ {
+ JScrollPane scroller = new JScrollPane();
+ scroller.setVerticalScrollBarPolicy(
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED );
+ scroller.setHorizontalScrollBarPolicy(
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
+ scroller.getViewport().setBackground( Color.white );
+ scroller.setViewportView( view );
+ return scroller;
+ }
+
+ /**
+ * Utility method to construct the hosts table column model.
+ * @return the table
+ */
+ private static TableColumnModel createContentHandlerColumnModel()
+ {
+ TableColumn iconColumn = new TableColumn( 0, 30, new
ClassicCellRenderer(), null );
+ iconColumn.setHeaderValue( "" );
+ iconColumn.setMaxWidth( 30 );
+ iconColumn.setMinWidth( 30 );
+ TableColumn typeColumn = new TableColumn( 1, 100, new
ClassicCellRenderer(), null );
+ typeColumn.setHeaderValue( "Type" );
+ TableColumnModel model = new DefaultTableColumnModel();
+ model.addColumn( iconColumn );
+ model.addColumn( typeColumn );
+ return model;
+ }
+
+ private class AddAction extends EditAction
+ {
+ public AddAction( String name )
+ {
+ super( name );
+ setEnabled( true );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ String type = JOptionPane.showInputDialog( m_parent, "Content
Type:" );
+ if( null == type )
+ {
+ return;
+ }
+ else
+ {
+ m_manager.addContentModel( type );
+ }
+ }
+ }
+
+ private class EditAction extends AbstractAction
+ {
+ public EditAction( String name )
+ {
+ super( name );
+ setEnabled( false );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ editSelection( (Component) event.getSource() );
+ }
+
+ public void editSelection( Component source )
+ {
+ try
+ {
+ final String title = "Content Handler";
+ final Dimension size = new Dimension( 400, 240 );
+ ClassicDialog dialog = ClassicDialog.createDialog( m_parent,
title, size );
+ ContentManager manager = m_manager.getContentManager(
m_selection );
+ if( null != manager )
+ {
+ PluginManagerPanel panel =
+ new PluginManagerPanel( dialog, manager,
ContentHandler.class );
+ dialog.getBody().add( panel );
+ dialog.setLocationRelativeTo( source );
+ dialog.setResizable( false );
+ dialog.setVisible(true);
+ }
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to construct plugin
dialog."
+ + "\nCODEBASE: "
+ +
getClass().getProtectionDomain().getCodeSource().getLocation().toString();
+ Logger logger = Logger.getLogger( "depot.prefs" );
+ logger.log( Level.SEVERE, error, e );
+ }
+ }
+ }
+
+ private class DeleteAction extends AbstractAction
+ {
+ public DeleteAction( String name )
+ {
+ super( name );
+ setEnabled( false );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ if( null == m_selection )
+ {
+ return;
+ }
+ try
+ {
+ m_manager.removeContentModel( m_selection );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to delete a content
handler plugin preferences node."
+ + "\nCODEBASE: "
+ +
getClass().getProtectionDomain().getCodeSource().getLocation().toString();
+ String message = ExceptionHelper.packException( error, e,
true );
+ System.out.println( message );
+ }
+ }
+ }
+
+ private static String MISC_IMG_PATH =
"net/dpml/depot/prefs/images/misc.png";
+}

Added:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/RegistryTableModel.java
==============================================================================
--- (empty file)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/RegistryTableModel.java
Mon May 23 16:03:51 2005
@@ -0,0 +1,181 @@
+/*
+ * Copyright 2005 Stephen McConnell
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.depot.prefs;
+
+import javax.swing.Icon;
+import javax.swing.table.AbstractTableModel;
+
+import net.dpml.transit.Transit;
+import net.dpml.transit.model.RegistryEvent;
+import net.dpml.transit.model.RegistryListener;
+import net.dpml.transit.manager.RegistryManager;
+
+/**
+ * Table model that maps table rows to child nodes of a supplied preferences
node.
+ */
+public class RegistryTableModel extends AbstractTableModel implements
RegistryListener
+{
+
//--------------------------------------------------------------------------
+ // static
+
//--------------------------------------------------------------------------
+
+ /**
+ * Default small icon path.
+ */
+ private static final String ICON_PATH =
"net/dpml/depot/prefs/images/item.gif";
+
+ /**
+ * Constant row identifier for the icon.
+ */
+ public static final int ICON = 0;
+
+ /**
+ * Constant row identifier for the name.
+ */
+ public static final int VALUE = 1;
+
+ /**
+ * Number of columns.
+ */
+ private static final int COLUMN_COUNT = 2;
+
+ /**
+ * Default small icon.
+ */
+ private static final Icon FEATURE_ICON =
+ IconHelper.createImageIcon(
+ RegistryTableModel.class.getClassLoader(), ICON_PATH, "Features" );
+
+ private final RegistryManager m_manager;
+
+
//--------------------------------------------------------------------------
+ // constructor
+
//--------------------------------------------------------------------------
+
+ /**
+ * Creation of a new table model that presents children of the supplied
preference
+ * node as table entries.
+ *
+ * @param prefs the preferences node that this model is displaying
+ */
+ public RegistryTableModel( RegistryManager manager )
+ {
+ super();
+ m_manager = manager;
+ manager.addRegistryListener( this );
+ }
+
+ protected void finalize()
+ {
+ try
+ {
+ m_manager.removeRegistryListener( this );
+ }
+ catch( Throwable e )
+ {
+ }
+ }
+
+
//--------------------------------------------------------------------------
+ // RegistryListener
+
//--------------------------------------------------------------------------
+
+ /**
+ * Notify all listeners of the addition of a content model.
+ * @param event the registry event
+ */
+ public void contentAdded( RegistryEvent event )
+ {
+ fireTableStructureChanged();
+ }
+
+ /**
+ * Notify all listeners of the removal of a content model.
+ * @param event the registry event
+ */
+ public void contentRemoved( RegistryEvent event )
+ {
+ fireTableStructureChanged();
+ }
+
+
//--------------------------------------------------------------------------
+ // NodeTableModel
+
//--------------------------------------------------------------------------
+
+ /**
+ * Returns the number of model columns.
+ * @return int the number of columns maintained by the model
+ */
+ public int getColumnCount()
+ {
+ return COLUMN_COUNT;
+ }
+
+ /**
+ * Returns the number of rows in the model. The value returned is
+ * equivilent to the number of elements in the list backing the model.
+ * @return int the number of rows maintained by the model
+ */
+ public int getRowCount()
+ {
+ try
+ {
+ return m_manager.getContentModels().length;
+ }
+ catch( Throwable e )
+ {
+ return 0;
+ }
+ }
+
+ /**
+ * Returns the feature object at the request column and row combination.
+ * If the col index is out of range the method returns the agent
corresponding
+ * to the row identifier.
+ * @param row the row index
+ * @param col the column index
+ * @return Object
+ */
+ public Object getValueAt( int row, int col )
+ {
+ Object result = "";
+ if( row > getRowCount() )
+ {
+ return result;
+ }
+
+ switch( col )
+ {
+ case ICON :
+ return FEATURE_ICON;
+ default:
+ return getHostAtRow( row );
+ }
+ }
+
+ private String getHostAtRow( int row )
+ {
+ try
+ {
+ return m_manager.getContentModels()[ row ].getContentType();
+ }
+ catch( Throwable e )
+ {
+ return "";
+ }
+ }
+}

Added:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/images/proxy.png
==============================================================================
Binary file. No diff available.

Added:
development/main/depot/station/src/main/net/dpml/depot/prefs/ProxyPanel.java
==============================================================================
--- (empty file)
+++
development/main/depot/station/src/main/net/dpml/depot/prefs/ProxyPanel.java
Mon May 23 16:03:51 2005
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2005 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.depot.prefs;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.File;
+import java.util.prefs.PreferenceChangeEvent;
+import java.util.prefs.PreferenceChangeListener;
+import java.util.prefs.Preferences;
+
+import javax.swing.AbstractAction;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.border.EmptyBorder;
+
+import net.dpml.depot.lang.DPML;
+import net.dpml.transit.Transit;
+import net.dpml.transit.cache.CacheHandler;
+
+
+/**
+ * Control panel for editing the proxy preferences.
+ *
+ * @author <a href="mailto:mcconnell AT osm.net";>OSM</a>
+ */
+class ProxyPanel extends JPanel
+{
+ //--------------------------------------------------------------
+ // static
+ //--------------------------------------------------------------
+
+ static EmptyBorder border5 = new EmptyBorder( 5, 5, 5, 5);
+
+ //--------------------------------------------------------------
+ // state
+ //--------------------------------------------------------------
+
+ private final JDialog m_parent;
+
+ //--------------------------------------------------------------
+ // constructor
+ //--------------------------------------------------------------
+
+ public ProxyPanel( JDialog parent ) throws Exception
+ {
+ m_parent = parent;
+ }
+
+}

Modified:
development/main/depot/station/src/main/net/dpml/depot/prefs/TransitPanel.java
==============================================================================
---
development/main/depot/station/src/main/net/dpml/depot/prefs/TransitPanel.java
(original)
+++
development/main/depot/station/src/main/net/dpml/depot/prefs/TransitPanel.java
Mon May 23 16:03:51 2005
@@ -122,8 +122,14 @@
hostPanel.add( buttonHolder, BorderLayout.SOUTH );

JPanel cachePanel = createCachePanel();
+ JPanel proxyPanel = createProxyPanel();
+ JPanel ladder = new JPanel();
+ ladder.setLayout( new BoxLayout( ladder, BoxLayout.Y_AXIS ) );
+ ladder.setBackground( Color.white );
+ ladder.add( proxyPanel );
+ ladder.add( cachePanel );

- add( cachePanel, BorderLayout.NORTH );
+ add( ladder, BorderLayout.NORTH );
add( hostPanel, BorderLayout.CENTER );
}

@@ -153,6 +159,37 @@
}
}

+ private JPanel createProxyPanel()
+ {
+ JLabel label =
+ IconHelper.createImageIconJLabel(
+ getClass().getClassLoader(),
+ "net/dpml/depot/prefs/images/proxy.png",
+ "Proxy",
+ "Proxy settings." );
+ label.setBorder( new EmptyBorder( 0, 5, 0, 0 ) );
+
+ JPanel holder = new JPanel();
+ holder.setLayout( new BoxLayout( holder, BoxLayout.Y_AXIS ) );
+ holder.setBorder( new EmptyBorder( 0, 6, 0, 6 ) );
+ holder.setBackground( Color.white );
+ JPanel panel = new JPanel();
+ panel.setBackground( Color.white );
+ panel.setLayout( new BorderLayout() );
+ panel.add( label, BorderLayout.WEST );
+ panel.setBorder(
+ new CompoundBorder(
+ new TitledBorder( null, "Proxy", TitledBorder.LEFT,
TitledBorder.TOP), border5 ) );
+ JButton button = new JButton( new ProxyAction( "Proxy" ) );
+ JPanel buttonHolder = new JPanel();
+ buttonHolder.setBackground( Color.white );
+ buttonHolder.setLayout( new BorderLayout() );
+ buttonHolder.add( button, BorderLayout.SOUTH );
+ panel.add( buttonHolder, BorderLayout.EAST );
+ holder.add( panel );
+ return holder;
+ }
+
private JPanel createCachePanel()
{
JLabel label =
@@ -184,6 +221,55 @@
return holder;
}

+ private class ProxyAction extends AbstractAction
+ {
+ ProxyAction( String name )
+ {
+ super( name );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ try
+ {
+ JDialog dialog = null;
+ if( m_parent instanceof Dialog )
+ {
+ dialog = new JDialog( (Dialog) m_parent, true );
+ }
+ else
+ {
+ dialog = new JDialog( (Frame) m_parent, true );
+ }
+
+ dialog.setTitle( "Proxy Settings" );
+ Dimension size = new Dimension( 400, 160 );
+
+ JPanel frame = new JPanel();
+ frame.setLayout( new BorderLayout() );
+ frame.setBackground( Color.white );
+ frame.setBorder( new EmptyBorder( 10, 6, 0, 6 ) );
+
+ JPanel panel = new ProxyPanel( dialog );
+ frame.add( panel, BorderLayout.CENTER );
+ dialog.setContentPane( frame );
+ dialog.setSize( size );
+ dialog.setLocationRelativeTo( (Component) event.getSource()
);
+ dialog.setResizable( true );
+ dialog.setVisible(true);
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to handle the 'Proxy'
action. "
+ + "\nCODEBASE: "
+ +
TransitPanel.class.getProtectionDomain().getCodeSource().getLocation().toString();
+ String message = ExceptionHelper.packException( error, e,
true );
+ System.err.println( message );
+ }
+ }
+ }
+
private class CacheAction extends AbstractAction
{
CacheAction( String name )

Added:
development/main/depot/station/src/main/net/dpml/depot/prefs/images/proxy.png
==============================================================================
Binary file. No diff available.

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/TransitPreferences.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/TransitPreferences.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/TransitPreferences.java
Mon May 23 16:03:51 2005
@@ -86,7 +86,7 @@
{
Preferences cache = root.node( "cache" );
setupCachePreferences( cache );
- Preferences hosts = root.node( "hosts" );
+ Preferences hosts = cache.node( "hosts" );
setupHostsPreferences( hosts );
root.putLong( "installation", new Date().getTime() );
}
@@ -128,10 +128,10 @@

private static void setupHostsPreferences( Preferences prefs ) throws
IOException, BackingStoreException
{
- setupNamedHost( prefs, "www.ibiblio.org",
"transit/authority/hosts/www.ibiblio.org.host" );
- setupNamedHost( prefs, "www.apache.org",
"transit/authority/hosts/www.apache.org.host" );
- setupNamedHost( prefs, "repository.dpml.net",
"transit/authority/hosts/repository.dpml.net.host" );
setupNamedHost( prefs, "local", "transit/authority/hosts/local.host"
);
+ setupNamedHost( prefs, "repository.dpml.net",
"transit/authority/hosts/repository.dpml.net.host" );
+ setupNamedHost( prefs, "www.apache.org",
"transit/authority/hosts/www.apache.org.host" );
+ setupNamedHost( prefs, "www.ibiblio.org",
"transit/authority/hosts/www.ibiblio.org.host" );
}

private static void setupNamedHost( Preferences prefs, String name,
String resource ) throws IOException

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/cache/FileCacheHandler.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/cache/FileCacheHandler.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/cache/FileCacheHandler.java
Mon May 23 16:03:51 2005
@@ -95,7 +95,7 @@

/**
* Creation of a new file based cache handler using system preferences.
- * @param prefs the root transit preferences
+ * @param prefs the file subsystem preferences
* @param resolver the location resolver
*/
public FileCacheHandler( LocationResolver resolver, Preferences prefs )
throws TransitException
@@ -134,12 +134,10 @@
// add a listener to the user preferences
//

- Preferences cachePrefs = getCachePreferences( prefs );
- cachePrefs.addPreferenceChangeListener( this );
-
+ prefs.addPreferenceChangeListener( this );
hostsNode.addNodeChangeListener( this );
- File cache = resolveCacheModely( cachePrefs );
- setLocalCacheModely( cache );
+ File cache = resolveCacheModely( prefs );
+ setLocalCacheDirectory( cache );
}

//
------------------------------------------------------------------------
@@ -182,14 +180,14 @@
}

File cache = resolveCacheModely( props );
- setLocalCacheModely( cache );
+ setLocalCacheDirectory( cache );
}

/**
* Set the local cache directory.
*
*/
- protected synchronized void setLocalCacheModely( File file )
+ protected synchronized void setLocalCacheDirectory( File file )
{
if( null == file )
{
@@ -544,7 +542,7 @@
if( "location".equals( key ) )
{
File cache = resolveCacheModely( prefs );
- setLocalCacheModely( cache );
+ setLocalCacheDirectory( cache );
}
}

@@ -603,11 +601,6 @@
// prefs utilities
//
------------------------------------------------------------------------

- private Preferences getCachePreferences( Preferences root ) throws
TransitException
- {
- return root.node( "cache" );
- }
-
private Preferences getHostsPreferences( Preferences root ) throws
TransitException
{
return root.node( "hosts" );

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/host/PreferencesResourceManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/host/PreferencesResourceManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/host/PreferencesResourceManager.java
Mon May 23 16:03:51 2005
@@ -146,7 +146,7 @@
Class[] params = new Class[]{
LocationResolver.class, Preferences.class};
Object[] args = new Object[]{
- m_resolver, m_preferences};
+ m_resolver, prefs };
Constructor cons = cls.getConstructor( params );
return (CacheHandler) cons.newInstance( args );
}

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/CacheManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/CacheManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/CacheManager.java
Mon May 23 16:03:51 2005
@@ -32,6 +32,7 @@
import java.util.prefs.PreferenceChangeListener;
import java.util.prefs.NodeChangeEvent;
import java.util.prefs.NodeChangeListener;
+import java.util.prefs.BackingStoreException;
import java.net.URI;
import java.net.UnknownHostException;

@@ -58,9 +59,17 @@
public class CacheManager extends PluginManager
implements CacheModel, NodeChangeListener , PluginListener
{
+ //
------------------------------------------------------------------------
+ // state
+ //
------------------------------------------------------------------------
+
private final List m_list = new LinkedList();
private File m_cache;

+ //
------------------------------------------------------------------------
+ // constructor
+ //
------------------------------------------------------------------------
+
public CacheManager( Logger logger, Preferences prefs ) throws
ModelException
{
super( logger, prefs );
@@ -70,7 +79,7 @@
//

File cache = resolveCacheDirectory( prefs );
- setLocalCacheDirectory( cache );
+ setCacheDirectory( cache );

//
// construct the hosts
@@ -98,10 +107,98 @@
}

//
------------------------------------------------------------------------
- // disposal
+ // CacheManager
//
------------------------------------------------------------------------

/**
+ * Return an array of content managers currently assigned to the registry.
+ * @return the content manager array
+ */
+ public HostManager[] getHostManagers()
+ {
+ return (HostManager[]) m_list.toArray( new HostManager[0] );
+ }
+
+ public void addHostModel( String id )
+ {
+ getPreferences().node( id );
+ }
+
+ public HostManager getHostManager( String id )
+ {
+ HostManager[] managers = getHostManagers();
+ for( int i=0; i<managers.length; i++ )
+ {
+ HostManager manager = managers[i];
+ if( id.equals( manager.getID() ) )
+ {
+ return manager;
+ }
+ }
+ return null;
+ }
+
+ public void removeHostModel( String id ) throws ModelException
+ {
+ try
+ {
+ if( getPreferences().nodeExists( id ) )
+ {
+ Preferences prefs = getPreferences().node( id );
+ prefs.removeNode();
+ }
+ }
+ catch( BackingStoreException e )
+ {
+ final String error =
+ "Preferences backing store access error during host model
removal."
+ + "\nPreferences: " + getPreferences()
+ + "\nHost ID: " + id;
+ throw new ModelException( error );
+ }
+ }
+
+
+ /**
+ * Set the local cache directory.
+ * @param file the cache directory
+ */
+ public synchronized void setCacheDirectory( File file )
+ {
+ if( null == file )
+ {
+ throw new NullPointerException( "file" );
+ }
+ File cache = file;
+ if( false == cache.isAbsolute() )
+ {
+ File anchor = getAnchorDirectory();
+ cache = new File( anchor, file.toString() );
+ cache.mkdirs();
+ }
+ if( null == m_cache )
+ {
+ final String message =
+ "Setting cache directory."
+ + "\nDirectory: " + cache;
+ getLogger().fine( message );
+ m_cache = cache;
+ }
+ else
+ {
+ if( false == m_cache.equals( cache ) )
+ {
+ final String message =
+ "Changing cache directory."
+ + "\nOld: " + m_cache
+ + "\nNew: " + cache;
+ getLogger().fine( message );
+ m_cache = cache;
+ }
+ }
+ }
+
+ /**
* Dispose of the manager.
*/
public void dispose()
@@ -131,6 +228,46 @@
}

//
------------------------------------------------------------------------
+ // CacheModel
+ //
------------------------------------------------------------------------
+
+ /**
+ * Return the directory to be used by the cache handler as the cache
directory.
+ * @return the cache directory.
+ */
+ public File getCacheDirectory()
+ {
+ return m_cache;
+ }
+
+ /**
+ * Return an array of hosts currently assigned to the cache.
+ * @return the host model array
+ */
+ public HostModel[] getHostModels()
+ {
+ return (HostModel[]) m_list.toArray( new HostModel[0] );
+ }
+
+ /**
+ * Add a cache change listener.
+ * @param listener the listener to add
+ */
+ public void addCacheListener( CacheListener listener )
+ {
+ super.addListener( listener );
+ }
+
+ /**
+ * Remove a cache change listener.
+ * @param listener the listener to remove
+ */
+ public void removeCacheListener( CacheListener listener )
+ {
+ super.removeListener( listener );
+ }
+
+ //
------------------------------------------------------------------------
// PluginListener (listens to changes to plugin uris)
//
------------------------------------------------------------------------

@@ -153,7 +290,7 @@
if( "location".equals( key ) )
{
File cache = resolveCacheDirectory( prefs );
- setLocalCacheDirectory( cache );
+ setCacheDirectory( cache );
}
}

@@ -254,42 +391,6 @@
return null;
}

- /**
- * Return the directory to be used by the cache handler as the cache
directory.
- * @return the cache directory.
- */
- public File getCacheDirectory()
- {
- return m_cache;
- }
-
- /**
- * Return an array of hosts currently assigned to the cache.
- * @return the host model array
- */
- public HostModel[] getHostModels()
- {
- return (HostModel[]) m_list.toArray( new HostModel[0] );
- }
-
- /**
- * Add a cache change listener.
- * @param listener the listener to add
- */
- public void addCacheListener( CacheListener listener )
- {
- super.addListener( listener );
- }
-
- /**
- * Remove a cache change listener.
- * @param listener the listener to remove
- */
- public void removeCacheListener( CacheListener listener )
- {
- super.removeListener( listener );
- }
-
public void processEvent( EventObject event )
{
if( event instanceof PluginChangeEvent )
@@ -313,7 +414,7 @@
}
}

- public void processHostEvent( HostNodeEvent event )
+ private void processHostEvent( HostNodeEvent event )
{
EventListener[] listeners = super.listeners();
for( int i=0; i<listeners.length; i++ )
@@ -388,41 +489,6 @@
return new File( cache );
}

- /**
- * Set the local cache directory.
- * @param file the cache directory
- */
- protected synchronized void setLocalCacheDirectory( File file )
- {
- if( null == file )
- {
- throw new NullPointerException( "file" );
- }
- File cache = file;
- if( false == cache.isAbsolute() )
- {
- File anchor = getAnchorDirectory();
- cache = new File( anchor, file.toString() );
- }
- if( null == m_cache )
- {
- final String message =
- "Setting cache directory."
- + "\nDirectory: " + cache;
- getLogger().fine( message );
- }
- else
- {
- final String message =
- "Changing cache directory."
- + "\nOld: " + m_cache
- + "\nNew: " + cache;
- getLogger().fine( message );
- }
- cache.mkdirs();
- m_cache = cache;
- }
-
private File getAnchorDirectory()
{
return Transit.DPML_DATA;

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/HostManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/HostManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/HostManager.java
Mon May 23 16:03:51 2005
@@ -86,158 +86,42 @@
m_enabled = prefs.getBoolean( "enabled", m_enabled );
m_priority = prefs.getInt( "priority", m_priority );
m_base = resolveBase( prefs );
- m_index = resolveIndex( m_base, prefs );
- m_identifier = resolveRequestIdentifier( m_base, prefs );
- m_authentication = resolvePasswordAuthentication( prefs );
- }
-
- private URL resolveBase( Preferences prefs ) throws
UnknownHostException, IOException
- {
- String baseSpec = prefs.get( "base", null );
- if( null == baseSpec )
- {
- final String error =
- "Undefined base url.";
- throw new UnknownHostException( error );
- }
- return new URL( baseSpec );
- }
-
- private URL resolveIndex( URL base, Preferences prefs ) throws
IOException
- {
- String indexSpec = prefs.get( "index", null );
- if( null != indexSpec )
- {
- return new URL( base, indexSpec );
- }
- else
+ if( m_base != null )
{
- return null;
+ m_index = resolveIndex( m_base, prefs );
+ m_identifier = resolveRequestIdentifier( m_base, prefs );
+ m_authentication = resolvePasswordAuthentication( prefs );
}
}

- //
------------------------------------------------------------------------
- // PreferenceChangeListener
- //
------------------------------------------------------------------------
+ //----------------------------------------------------------------------
+ // HostManager
+ //----------------------------------------------------------------------

- public void preferenceChange( PreferenceChangeEvent event )
+ public void setBaseURL( URL url )
{
- String key = event.getKey();
- if( "enabled".equals( key ) )
+ Preferences prefs = getPreferences();
+ if( null == url )
{
- boolean flag = event.getNode().getBoolean( "enabled", m_enabled
);
- if( m_enabled != flag )
- {
- m_enabled = flag;
- EnabledEvent e = new EnabledEvent( this, m_enabled );
- enqueueEvent( e );
- }
+ prefs.putBoolean( "enabled", false );
+ prefs.remove( "base" );
}
- else if( "trusted".equals( key ) )
- {
- boolean flag = event.getNode().getBoolean( "trusted", m_trusted
);
- if( m_trusted != flag )
- {
- m_trusted = flag;
- TrustedEvent e = new TrustedEvent( this, m_trusted );
- enqueueEvent( e );
- }
- }
- else if( "priority".equals( key ) )
- {
- int priority = event.getNode().getInt( "priority", m_priority );
- if( m_priority != priority )
- {
- m_priority = priority;
- PriorityEvent e = new PriorityEvent( this, m_priority );
- enqueueEvent( e );
- }
- }
- else if( "name".equals( key ) )
- {
- String name = event.getNode().get( "name", m_name );
- if( m_name != name )
- {
- m_name = name;
- NameChangeEvent e = new NameChangeEvent( this, m_name );
- enqueueEvent( e );
- }
- }
- else if( "modified".equals( key ) )
+ else
{
- // this is a trigger marking modification to any of the
- // attributes "base", "username", "password", "prompt" or
"scheme"
- // in which case we notify a host controller of the change via
- // a single HostChangeEvent
-
- synchronized( this )
- {
- Preferences prefs = event.getNode();
- try
- {
- URL base = resolveBase( prefs );
- URL index = resolveIndex( m_base, prefs );
- RequestIdentifier identifier = resolveRequestIdentifier(
m_base, prefs );
- PasswordAuthentication authentication =
resolvePasswordAuthentication( prefs );
-
- m_base = base;
- m_index = index;
- m_identifier = identifier;
- m_authentication = authentication;
-
- HostChangeEvent e =
- new HostChangeEvent( this, base, index, identifier,
authentication );
- enqueueEvent( e );
- }
- catch( UnknownHostException uhe )
- {
- final String error =
- "Unable to propergate change event due to an
unresolved host."
- + "\nPreferences Node: " + prefs
- + "\nHost path: " + prefs.get( "base", null );
- getLogger().log( Level.SEVERE, error, uhe );
- }
- catch( IOException ioe )
- {
- final String error =
- "Unable to propergate change event due to an
unexpected IO error."
- + "\nPreferences Node: " + prefs;
- getLogger().log( Level.SEVERE, error, ioe );
- }
- }
+ prefs.put( "base", url.toExternalForm() );
}
}

- private RequestIdentifier resolveRequestIdentifier( URL base,
Preferences prefs )
+ public void setTrusted( boolean flag )
{
- String scheme = prefs.get( "scheme", "" );
- String prompt = prefs.get( "prompt", "" );
- String protocol = base.getProtocol();
- String host = base.getHost();
- int port = base.getPort();
- if( port == 0 )
- {
- if( protocol.equals( "http" ) )
- {
- port = HTTP_PORT;
- }
- else if( protocol.equals( "ftp" ) )
- {
- port = FTP_PORT;
- }
- else if( protocol.equals( "https" ) )
- {
- port = HTTPS_PORT;
- }
- }
- return new RequestIdentifier( host, port, protocol, scheme, prompt );
+ Preferences prefs = getPreferences();
+ prefs.putBoolean( "trusted", flag );
}

- private PasswordAuthentication resolvePasswordAuthentication(
Preferences prefs )
+ public void setEnabled( boolean flag )
{
- String username = prefs.get( "username", "" );
- String password = prefs.get( "password", "" );
- return new PasswordAuthentication( username, password.toCharArray()
);
+ Preferences prefs = getPreferences();
+ prefs.putBoolean( "enabled", flag );
}

//----------------------------------------------------------------------
@@ -391,10 +275,161 @@
super.removeListener( listener );
}

+ //
------------------------------------------------------------------------
+ // PreferenceChangeListener
+ //
------------------------------------------------------------------------
+
+ public void preferenceChange( PreferenceChangeEvent event )
+ {
+ String key = event.getKey();
+ if( "enabled".equals( key ) )
+ {
+ boolean flag = event.getNode().getBoolean( "enabled", m_enabled
);
+ if( m_enabled != flag )
+ {
+ m_enabled = flag;
+ EnabledEvent e = new EnabledEvent( this, m_enabled );
+ enqueueEvent( e );
+ }
+ }
+ else if( "trusted".equals( key ) )
+ {
+ boolean flag = event.getNode().getBoolean( "trusted", m_trusted
);
+ if( m_trusted != flag )
+ {
+ m_trusted = flag;
+ TrustedEvent e = new TrustedEvent( this, m_trusted );
+ enqueueEvent( e );
+ }
+ }
+ else if( "priority".equals( key ) )
+ {
+ int priority = event.getNode().getInt( "priority", m_priority );
+ if( m_priority != priority )
+ {
+ m_priority = priority;
+ PriorityEvent e = new PriorityEvent( this, m_priority );
+ enqueueEvent( e );
+ }
+ }
+ else if( "name".equals( key ) )
+ {
+ String name = event.getNode().get( "name", m_name );
+ if( m_name != name )
+ {
+ m_name = name;
+ NameChangeEvent e = new NameChangeEvent( this, m_name );
+ enqueueEvent( e );
+ }
+ }
+ else if( "modified".equals( key ) )
+ {
+ // this is a trigger marking modification to any of the
+ // attributes "base", "username", "password", "prompt" or
"scheme"
+ // in which case we notify a host controller of the change via
+ // a single HostChangeEvent
+
+ synchronized( this )
+ {
+ Preferences prefs = event.getNode();
+ try
+ {
+ URL base = resolveBase( prefs );
+ URL index = resolveIndex( m_base, prefs );
+ RequestIdentifier identifier = resolveRequestIdentifier(
m_base, prefs );
+ PasswordAuthentication authentication =
resolvePasswordAuthentication( prefs );
+
+ m_base = base;
+ m_index = index;
+ m_identifier = identifier;
+ m_authentication = authentication;
+
+ HostChangeEvent e =
+ new HostChangeEvent( this, base, index, identifier,
authentication );
+ enqueueEvent( e );
+ }
+ catch( UnknownHostException uhe )
+ {
+ final String error =
+ "Unable to propergate change event due to an
unresolved host."
+ + "\nPreferences Node: " + prefs
+ + "\nHost path: " + prefs.get( "base", null );
+ getLogger().log( Level.SEVERE, error, uhe );
+ }
+ catch( IOException ioe )
+ {
+ final String error =
+ "Unable to propergate change event due to an
unexpected IO error."
+ + "\nPreferences Node: " + prefs;
+ getLogger().log( Level.SEVERE, error, ioe );
+ }
+ }
+ }
+ }
+
//----------------------------------------------------------------------
// internal
//----------------------------------------------------------------------

+ private RequestIdentifier resolveRequestIdentifier( URL base,
Preferences prefs )
+ {
+ String scheme = prefs.get( "scheme", "" );
+ String prompt = prefs.get( "prompt", "" );
+ String protocol = base.getProtocol();
+ String host = base.getHost();
+ int port = base.getPort();
+ if( port == 0 )
+ {
+ if( protocol.equals( "http" ) )
+ {
+ port = HTTP_PORT;
+ }
+ else if( protocol.equals( "ftp" ) )
+ {
+ port = FTP_PORT;
+ }
+ else if( protocol.equals( "https" ) )
+ {
+ port = HTTPS_PORT;
+ }
+ }
+ return new RequestIdentifier( host, port, protocol, scheme, prompt );
+ }
+
+ private PasswordAuthentication resolvePasswordAuthentication(
Preferences prefs )
+ {
+ String username = prefs.get( "username", "" );
+ String password = prefs.get( "password", "" );
+ return new PasswordAuthentication( username, password.toCharArray()
);
+ }
+
+ private URL resolveBase( Preferences prefs ) throws
UnknownHostException, IOException
+ {
+ String baseSpec = prefs.get( "base", null );
+ if( null == baseSpec )
+ {
+ return null;
+ }
+ return new URL( baseSpec );
+ }
+
+ private URL resolveIndex( URL base, Preferences prefs ) throws
IOException
+ {
+ if( null == base )
+ {
+ return null;
+ }
+ String indexSpec = prefs.get( "index", null );
+ if( null != indexSpec )
+ {
+ return new URL( base, indexSpec );
+ }
+ else
+ {
+ return null;
+ }
+ }
+
protected void processEvent( EventObject event )
{
if( event instanceof PluginChangeEvent )

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/PluginManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/PluginManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/PluginManager.java
Mon May 23 16:03:51 2005
@@ -41,7 +41,7 @@
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
* @version $Id: StandardTransitDirector.java 2480 2005-05-10 04:44:32Z
mcconnell AT dpml.net $
*/
-abstract class PluginManager extends EventProducer implements PluginModel,
PreferenceChangeListener
+public abstract class PluginManager extends EventProducer implements
PluginModel, PreferenceChangeListener
{
private final Preferences m_preferences;

@@ -75,6 +75,30 @@
}

//
------------------------------------------------------------------------
+ // PluginManager
+ //
------------------------------------------------------------------------
+
+ /**
+ * Set the plugin uri value.
+ * @return the plugin uri
+ */
+ public void setPluginURI( URI uri )
+ {
+ synchronized( m_lock )
+ {
+ m_uri = uri;
+ if( null != uri )
+ {
+ m_preferences.put( "uri", uri.toString() );
+ }
+ else
+ {
+ m_preferences.remove( "uri" );
+ }
+ }
+ }
+
+ //
------------------------------------------------------------------------
// PluginModel
//
------------------------------------------------------------------------


Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/manager/RegistryManager.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/manager/RegistryManager.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/manager/RegistryManager.java
Mon May 23 16:03:51 2005
@@ -26,6 +26,7 @@
import java.util.prefs.Preferences;
import java.util.prefs.NodeChangeEvent;
import java.util.prefs.NodeChangeListener;
+import java.util.prefs.BackingStoreException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.net.URI;
@@ -92,10 +93,58 @@
}

//
------------------------------------------------------------------------
- // disposal
+ // RegistryManager
//
------------------------------------------------------------------------

/**
+ * Return an array of content managers currently assigned to the registry.
+ * @return the content manager array
+ */
+ public ContentManager[] getContentManagers()
+ {
+ return (ContentManager[]) m_list.toArray( new ContentManager[0] );
+ }
+
+ public ContentManager getContentManager( String type )
+ {
+ ContentManager[] managers = getContentManagers();
+ for( int i=0; i<managers.length; i++ )
+ {
+ ContentManager manager = managers[i];
+ if( type.equals( manager.getContentType() ) )
+ {
+ return manager;
+ }
+ }
+ return null;
+ }
+
+ public void addContentModel( String type )
+ {
+ getPreferences().node( type );
+ }
+
+ public void removeContentModel( String type ) throws ModelException
+ {
+ try
+ {
+ if( getPreferences().nodeExists( type ) )
+ {
+ Preferences prefs = getPreferences().node( type );
+ prefs.removeNode();
+ }
+ }
+ catch( BackingStoreException e )
+ {
+ final String error =
+ "Preferences backing store access error during content model
removal."
+ + "\nPreferences: " + getPreferences()
+ + "\nContent Type: " + type;
+ throw new ModelException( error );
+ }
+ }
+
+ /**
* Dispose of the manager.
*/
public void dispose()
@@ -125,37 +174,6 @@
}

//
------------------------------------------------------------------------
- // PluginListener (listens to changes to plugin uris)
- //
------------------------------------------------------------------------
-
- public void pluginChanged( PluginChangeEvent event )
- {
- getLogger().info( "plugin changed: " + event.getPluginURI() );
- }
-
- //
------------------------------------------------------------------------
- // NodeChangeListener (listens to content prefs node addition and
removal)
- //
------------------------------------------------------------------------
-
- /**
- * Handle the addition of a content handler configuration following a
- * preferences node change.
- *
- * @param event the node addition event
- */
- public void childAdded( NodeChangeEvent event )
- {
- Preferences prefs = event.getChild();
- addContentModel( prefs, true );
- }
-
- public void childRemoved( NodeChangeEvent event )
- {
- Preferences prefs = event.getChild();
- removeContentModel( prefs );
- }
-
- //
------------------------------------------------------------------------
// RegistryManager
//
------------------------------------------------------------------------

@@ -187,6 +205,37 @@
}

//
------------------------------------------------------------------------
+ // PluginListener (listens to changes to plugin uris)
+ //
------------------------------------------------------------------------
+
+ public void pluginChanged( PluginChangeEvent event )
+ {
+ getLogger().info( "plugin changed: " + event.getPluginURI() );
+ }
+
+ //
------------------------------------------------------------------------
+ // NodeChangeListener (listens to content prefs node addition and
removal)
+ //
------------------------------------------------------------------------
+
+ /**
+ * Handle the addition of a content handler configuration following a
+ * preferences node change.
+ *
+ * @param event the node addition event
+ */
+ public void childAdded( NodeChangeEvent event )
+ {
+ Preferences prefs = event.getChild();
+ addContentModel( prefs, true );
+ }
+
+ public void childRemoved( NodeChangeEvent event )
+ {
+ Preferences prefs = event.getChild();
+ removeContentModel( prefs );
+ }
+
+ //
------------------------------------------------------------------------
// internal
//
------------------------------------------------------------------------


Modified:
development/main/transit/core/handler/src/test/net/dpml/transit/manager/ProxyManagerTestCase.java
==============================================================================
---
development/main/transit/core/handler/src/test/net/dpml/transit/manager/ProxyManagerTestCase.java
(original)
+++
development/main/transit/core/handler/src/test/net/dpml/transit/manager/ProxyManagerTestCase.java
Mon May 23 16:03:51 2005
@@ -162,9 +162,9 @@
{
event.getProxyModel().removeProxyListener( this );
String result = event.getProxyExcludes();
- assertNotNull( "excludes", result );
+ assertNotNull( "excludes-not-null", result );
String expected =
"http://www.osm.net|http://repository.dpml.net";;
- assertEquals( "excludes", expected.length(), result.length() );
+ assertEquals( "excludes-length", expected.length(),
result.length() );
}

public void proxyExcludesChanged( ProxyExcludesEvent event )
@@ -195,5 +195,13 @@
{
}
}
+
+ static
+ {
+ System.setProperty(
+ "java.util.logging.config.class",
+ "net.dpml.transit.logging.ConfigurationHandler" );
+ }
+
}




  • svn commit: r2659 - in development/main: depot/console depot/console/src/main/net/dpml/depot/lang depot/prefs depot/prefs/src/main/net/dpml/depot/prefs depot/prefs/src/main/net/dpml/depot/prefs/images depot/station/src/main/net/dpml/depot/prefs depot/station/src/main/net/dpml/depot/prefs/images transit/core/handler/src/main/net/dpml/transit transit/core/handler/src/main/net/dpml/transit/cache transit/core/handler/src/main/net/dpml/transit/host transit/core/handler/src/main/net/dpml/transit/manager transit/core/handler/src/test/net/dpml/transit/manager, mcconnell, 05/23/2005

Archive powered by MHonArc 2.6.24.

Top of Page