Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2846 - in development/main: depot/console/src/main/net/dpml/depot depot/console/src/main/net/dpml/depot/profile depot/prefs/src/main/net/dpml/depot/prefs depot/station/src/main/net/dpml/depot/station transit/core/handler/src/main/net/dpml/transit/home

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: r2846 - in development/main: depot/console/src/main/net/dpml/depot depot/console/src/main/net/dpml/depot/profile depot/prefs/src/main/net/dpml/depot/prefs depot/station/src/main/net/dpml/depot/station transit/core/handler/src/main/net/dpml/transit/home
  • Date: Mon, 13 Jun 2005 20:19:41 -0400

Author: mcconnell AT dpml.net
Date: Mon Jun 13 20:19:39 2005
New Revision: 2846

Added:

development/main/depot/console/src/main/net/dpml/depot/profile/DepotEvent.java

development/main/depot/console/src/main/net/dpml/depot/profile/DepotListener.java

development/main/depot/console/src/main/net/dpml/depot/profile/ProfileHome.java

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

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

development/main/transit/core/handler/src/main/net/dpml/transit/home/Removable.java
Modified:
development/main/depot/console/src/main/net/dpml/depot/Main.java

development/main/depot/console/src/main/net/dpml/depot/profile/AbstractPluginProfileStorage.java

development/main/depot/console/src/main/net/dpml/depot/profile/ApplicationProfile.java

development/main/depot/console/src/main/net/dpml/depot/profile/BootstrapProfile.java

development/main/depot/console/src/main/net/dpml/depot/profile/DepotModel.java

development/main/depot/console/src/main/net/dpml/depot/profile/PluginProfile.java
development/main/depot/console/src/main/net/dpml/depot/profile/Profile.java

development/main/depot/console/src/main/net/dpml/depot/profile/ProfileStorage.java

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

development/main/depot/station/src/main/net/dpml/depot/station/ActivationGroupProfile.java

development/main/depot/station/src/main/net/dpml/depot/station/ActivationGroupStorage.java

development/main/depot/station/src/main/net/dpml/depot/station/ActivationProfile.java

development/main/depot/station/src/main/net/dpml/depot/station/ActivationStorage.java

development/main/depot/station/src/main/net/dpml/depot/station/CodeBaseProfile.java
Log:
Build up the aplication profiles to support event generation in readiness for
inclusion under the depot editor.

Modified: development/main/depot/console/src/main/net/dpml/depot/Main.java
==============================================================================
--- development/main/depot/console/src/main/net/dpml/depot/Main.java
(original)
+++ development/main/depot/console/src/main/net/dpml/depot/Main.java Mon
Jun 13 20:19:39 2005
@@ -487,7 +487,7 @@
{
try
{
- return manager.getProfile( target );
+ return manager.getApplicationProfile( target );
}
catch( UnknownKeyException e )
{

Modified:
development/main/depot/console/src/main/net/dpml/depot/profile/AbstractPluginProfileStorage.java
==============================================================================
---
development/main/depot/console/src/main/net/dpml/depot/profile/AbstractPluginProfileStorage.java
(original)
+++
development/main/depot/console/src/main/net/dpml/depot/profile/AbstractPluginProfileStorage.java
Mon Jun 13 20:19:39 2005
@@ -46,32 +46,6 @@
}

//
------------------------------------------------------------------------
- // ModificationListener
- //
------------------------------------------------------------------------
-
- /**
- * Notify a listener of a change to the manager modification date.
- * @param event the modification event
- */
- public void modified( ModificationEvent event )
- {
- if( getStoragePolicy() )
- {
- try
- {
- PluginProfile manager = (PluginProfile) event.getModel();
- Date date = new Date();
- store( manager );
- manager.setCreationDate( date );
- }
- catch( Throwable e )
- {
- getLogger().error( "storage failure", e );
- }
- }
- }
-
- //
------------------------------------------------------------------------
// utils
//
------------------------------------------------------------------------


Modified:
development/main/depot/console/src/main/net/dpml/depot/profile/ApplicationProfile.java
==============================================================================
---
development/main/depot/console/src/main/net/dpml/depot/profile/ApplicationProfile.java
(original)
+++
development/main/depot/console/src/main/net/dpml/depot/profile/ApplicationProfile.java
Mon Jun 13 20:19:39 2005
@@ -35,7 +35,7 @@
private Connection m_connection;

public ApplicationProfile(
- Logger logger, Date creation, Home home, String id, String title,
+ Logger logger, Date creation, ProfileHome home, String id, String
title,
Properties properties, boolean command, Connection connection )
{
super( logger, creation, home, id, title, properties );
@@ -44,6 +44,10 @@
m_command = command;
}

+ //----------------------------------------------------------------------
+ // impl
+ //----------------------------------------------------------------------
+
public boolean getCommandPolicy()
{
return m_command;

Modified:
development/main/depot/console/src/main/net/dpml/depot/profile/BootstrapProfile.java
==============================================================================
---
development/main/depot/console/src/main/net/dpml/depot/profile/BootstrapProfile.java
(original)
+++
development/main/depot/console/src/main/net/dpml/depot/profile/BootstrapProfile.java
Mon Jun 13 20:19:39 2005
@@ -37,7 +37,7 @@
private boolean m_command;

public BootstrapProfile(
- Logger logger, Date creation, Home home, String id, String title,
+ Logger logger, Date creation, ProfileHome home, String id, String
title,
Properties properties, boolean command, Connection connection,
String classname, String[] classpath )
throws NullPointerException

Added:
development/main/depot/console/src/main/net/dpml/depot/profile/DepotEvent.java
==============================================================================
--- (empty file)
+++
development/main/depot/console/src/main/net/dpml/depot/profile/DepotEvent.java
Mon Jun 13 20:19:39 2005
@@ -0,0 +1,45 @@
+/*
+ * 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.profile;
+
+import java.util.EventObject;
+
+/**
+ * An event pertaining to the Depot collection of application profiles.
+ */
+public class DepotEvent extends EventObject
+{
+ ApplicationProfile m_profile;
+
+ public DepotEvent( DepotModel model, ApplicationProfile profile )
+ {
+ super( model );
+ m_profile = profile;
+ }
+
+ public ApplicationProfile getApplicationProfile()
+ {
+ return m_profile;
+ }
+
+ public DepotModel getDepotModel()
+ {
+ return (DepotModel) super.getSource();
+ }
+}

Added:
development/main/depot/console/src/main/net/dpml/depot/profile/DepotListener.java
==============================================================================
--- (empty file)
+++
development/main/depot/console/src/main/net/dpml/depot/profile/DepotListener.java
Mon Jun 13 20:19:39 2005
@@ -0,0 +1,40 @@
+/*
+ * 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.profile;
+
+import java.util.EventListener;
+
+/**
+ * A ProxyListener maintains information about the configuration of
+ * tranist proxy settings.
+ */
+public interface DepotListener extends EventListener
+{
+ /**
+ * Notify the listener of the addition of a new application profile.
+ * @param event the depot event
+ */
+ void profileAdded( DepotEvent event );
+
+ /**
+ * Notify a listener of the removal of an application profile.
+ * @param event the depot event
+ */
+ void profileRemoved( DepotEvent event );
+}

Modified:
development/main/depot/console/src/main/net/dpml/depot/profile/DepotModel.java
==============================================================================
---
development/main/depot/console/src/main/net/dpml/depot/profile/DepotModel.java
(original)
+++
development/main/depot/console/src/main/net/dpml/depot/profile/DepotModel.java
Mon Jun 13 20:19:39 2005
@@ -21,11 +21,17 @@
import java.net.URI;
import java.util.Properties;
import java.util.Date;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Collections;
+import java.util.EventObject;
+import java.util.EventListener;

import net.dpml.transit.home.Home;
import net.dpml.transit.model.Logger;
import net.dpml.transit.model.ModificationEvent;
import net.dpml.transit.model.UnknownKeyException;
+import net.dpml.transit.model.DuplicateKeyException;
import net.dpml.transit.model.DefaultModel;

/**
@@ -34,24 +40,56 @@
*/
public class DepotModel extends DefaultModel
{
- private ApplicationProfile[] m_profiles;
+ private final List m_list = Collections.synchronizedList( new
LinkedList() );

public DepotModel( Logger logger, Date creation, Home home,
ApplicationProfile[] profiles )
- throws NullPointerException
+ throws NullPointerException, ProfileException
{
super( logger, creation, home );

- m_profiles = profiles;
+ for( int i=0; i<profiles.length; i++ )
+ {
+ ApplicationProfile profile = profiles[i];
+ try
+ {
+ addApplicationProfile( profile, false );
+ }
+ catch( DuplicateKeyException e )
+ {
+ final String error =
+ "Cannot construct depot profile due to a duplicate
application key.";
+ throw new ProfileException( error, e );
+ }
+ }
}

- public ApplicationProfile[] getProfiles()
+ public void addApplicationProfile( ApplicationProfile profile ) throws
DuplicateKeyException
{
- return m_profiles;
+ addApplicationProfile( profile, true );
}

- public ApplicationProfile getProfile( String key ) throws
UnknownKeyException
+ public void removeApplicationProfile( ApplicationProfile profile )
{
- ApplicationProfile[] profiles = getProfiles();
+ synchronized( m_lock )
+ {
+ profile.dispose();
+ m_list.remove( profile );
+ ProfileRemovedEvent event = new ProfileRemovedEvent( this,
profile );
+ super.enqueueEvent( event );
+ }
+ }
+
+ public ApplicationProfile[] getApplicationProfiles()
+ {
+ synchronized( m_lock )
+ {
+ return (ApplicationProfile[]) m_list.toArray( new
ApplicationProfile[0] );
+ }
+ }
+
+ public ApplicationProfile getApplicationProfile( String key ) throws
UnknownKeyException
+ {
+ ApplicationProfile[] profiles = getApplicationProfiles();
for( int i=0; i<profiles.length; i++ )
{
ApplicationProfile profile = profiles[i];
@@ -62,4 +100,113 @@
}
throw new UnknownKeyException( key );
}
+
+ /**
+ * Add a depot content change listener.
+ * @param listener the registry change listener to add
+ */
+ public void addDepotListener( DepotListener listener )
+ {
+ super.addListener( listener );
+ }
+
+ /**
+ * Remove a depot content change listener.
+ * @param listener the registry change listener to remove
+ */
+ public void removeDepotListener( DepotListener listener )
+ {
+ super.removeListener( listener );
+ }
+
+ protected void processEvent( EventObject event )
+ {
+ if( event instanceof DepotEvent )
+ {
+ processDepotEvent( (DepotEvent) event );
+ }
+ else
+ {
+ super.processEvent( event );
+ }
+ }
+
+ private void addApplicationProfile( ApplicationProfile profile, boolean
notify )
+ throws DuplicateKeyException
+ {
+ synchronized( m_lock )
+ {
+ String key = profile.getID();
+ try
+ {
+ ApplicationProfile current = getApplicationProfile( key );
+ throw new DuplicateKeyException( key );
+ }
+ catch( UnknownKeyException e )
+ {
+ m_list.add( profile );
+ if( notify )
+ {
+ ProfileAddedEvent event = new ProfileAddedEvent( this,
profile );
+ enqueueEvent( event );
+ }
+ }
+ }
+ }
+
+ private void processDepotEvent( DepotEvent event )
+ {
+ EventListener[] listeners = super.listeners();
+ for( int i=0; i<listeners.length; i++ )
+ {
+ EventListener listener = listeners[i];
+ if( listener instanceof DepotListener )
+ {
+ DepotListener rl = (DepotListener) listener;
+ if( event instanceof ProfileAddedEvent )
+ {
+ try
+ {
+ rl.profileAdded( event );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "DepotListener profile addition notification
error.";
+ getLogger().error( error, e );
+ }
+ }
+ else if( event instanceof ProfileRemovedEvent )
+ {
+ try
+ {
+ rl.profileRemoved( event );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "DepotListener profile removed notification
error.";
+ getLogger().error( error, e );
+ }
+ }
+ }
+ }
+ }
+
+ static class ProfileAddedEvent extends DepotEvent
+ {
+ public ProfileAddedEvent( DepotModel source, ApplicationProfile
profile )
+ {
+ super( source, profile );
+ }
+ }
+
+ static class ProfileRemovedEvent extends DepotEvent
+ {
+ public ProfileRemovedEvent( DepotModel source, ApplicationProfile
profile )
+ {
+ super( source, profile );
+ }
+ }
+
}

Modified:
development/main/depot/console/src/main/net/dpml/depot/profile/PluginProfile.java
==============================================================================
---
development/main/depot/console/src/main/net/dpml/depot/profile/PluginProfile.java
(original)
+++
development/main/depot/console/src/main/net/dpml/depot/profile/PluginProfile.java
Mon Jun 13 20:19:39 2005
@@ -34,7 +34,7 @@
private URI m_uri;

public PluginProfile(
- Logger logger, Date creation, Home home, String id, String title,
+ Logger logger, Date creation, ProfileHome home, String id, String
title,
Properties properties, boolean command, Connection connection, URI uri
)
{
super( logger, creation, home, id, title, properties, command,
connection );

Modified:
development/main/depot/console/src/main/net/dpml/depot/profile/Profile.java
==============================================================================
---
development/main/depot/console/src/main/net/dpml/depot/profile/Profile.java
(original)
+++
development/main/depot/console/src/main/net/dpml/depot/profile/Profile.java
Mon Jun 13 20:19:39 2005
@@ -21,30 +21,38 @@
import java.net.URI;
import java.util.Properties;
import java.util.Date;
+import java.util.EventObject;
+import java.util.EventListener;

import net.dpml.transit.home.Home;
import net.dpml.transit.model.Logger;
import net.dpml.transit.model.ModificationEvent;
import net.dpml.transit.model.DefaultModel;
+import net.dpml.transit.model.Disposable;
+import net.dpml.transit.model.DisposalEvent;
+import net.dpml.transit.model.DisposalListener;

/**
* A ProfileModel maintains information about the configuration
* of an application profile.
*/
-public class Profile extends DefaultModel
+public class Profile extends DefaultModel implements Disposable
{
+ private final ProfileHome m_home;
private final String m_id;
+
private String m_title;
private Properties m_properties;

public Profile(
- Logger logger, Date creation, Home home, String id, String title,
Properties properties )
+ Logger logger, Date creation, ProfileHome home, String id, String
title, Properties properties )
{
super( logger, creation, home );

m_id = id;
m_title = title;
m_properties = properties;
+ m_home = home;
}

public String getID()
@@ -71,4 +79,88 @@
{
m_properties = properties;
}
+
+ //----------------------------------------------------------------------
+ // Disposable
+ //----------------------------------------------------------------------
+
+ /**
+ * Add a disposal listener to the model.
+ * @param listener the listener to add
+ */
+ public void addDisposalListener( DisposalListener listener )
+ {
+ super.addListener( listener );
+ }
+
+ /**
+ * Remove a disposal listener from the model.
+ * @param listener the listener to remove
+ */
+ public void removeDisposalListener( DisposalListener listener )
+ {
+ super.removeListener( listener );
+ }
+
+ public void dispose()
+ {
+ VetoableDisposalEvent veto = new VetoableDisposalEvent( this );
+ enqueueEvent( veto, false );
+ DisposalEvent disposal = new DisposalEvent( this );
+ enqueueEvent( disposal, false );
+ m_home.remove();
+ }
+
+ protected void processEvent( EventObject event )
+ {
+ if( event instanceof DisposalEvent )
+ {
+ processDisposalEvent( (DisposalEvent) event );
+ }
+ else
+ {
+ super.processEvent( event );
+ }
+ }
+
+ private void processDisposalEvent( DisposalEvent eventObject )
+ {
+ DisposalEvent event = (DisposalEvent) eventObject;
+ EventListener[] listeners = listeners();
+ for( int i=0; i<listeners.length; i++ )
+ {
+ EventListener listener = listeners[i];
+ if( listener instanceof DisposalListener )
+ {
+ DisposalListener pl = (DisposalListener) listener;
+ if( event instanceof VetoableDisposalEvent )
+ {
+ pl.disposing( event );
+ }
+ else
+ {
+ try
+ {
+ pl.disposed( event );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Disposal listener notification error.";
+ getLogger().error( error, e );
+ }
+ }
+ }
+ }
+ }
+
+ private static class VetoableDisposalEvent extends DisposalEvent
+ {
+ public VetoableDisposalEvent( Profile source )
+ {
+ super( source );
+ }
+ }
+
+
}

Added:
development/main/depot/console/src/main/net/dpml/depot/profile/ProfileHome.java
==============================================================================
--- (empty file)
+++
development/main/depot/console/src/main/net/dpml/depot/profile/ProfileHome.java
Mon Jun 13 20:19:39 2005
@@ -0,0 +1,30 @@
+/*
+ * 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.profile;
+
+import net.dpml.transit.home.Home;
+import net.dpml.transit.home.Removable;
+
+/**
+ * A ProxyListener maintains information about the configuration of
+ * tranist proxy settings.
+ */
+public interface ProfileHome extends Home, Removable
+{
+}

Modified:
development/main/depot/console/src/main/net/dpml/depot/profile/ProfileStorage.java
==============================================================================
---
development/main/depot/console/src/main/net/dpml/depot/profile/ProfileStorage.java
(original)
+++
development/main/depot/console/src/main/net/dpml/depot/profile/ProfileStorage.java
Mon Jun 13 20:19:39 2005
@@ -26,14 +26,14 @@
import java.util.prefs.Preferences;

import net.dpml.transit.home.Home;
+import net.dpml.transit.home.Removable;
import net.dpml.transit.model.Logger;
-import net.dpml.transit.model.ModificationEvent;
import net.dpml.transit.unit.AbstractStorageUnit;

/**
* A ProfileHome maintains a persistent application profile.
*/
-public abstract class ProfileStorage extends AbstractStorageUnit implements
Home
+public abstract class ProfileStorage extends AbstractStorageUnit implements
ProfileHome
{
//
------------------------------------------------------------------------
// constructor
@@ -47,28 +47,18 @@
}

//
------------------------------------------------------------------------
- // ModificationListener
+ // Removable
//
------------------------------------------------------------------------

- /**
- * Notify a listener of a change to the manager modification date.
- * @param event the modification event
- */
- public void modified( ModificationEvent event )
+ public void remove()
{
- if( getStoragePolicy() )
+ try
{
- try
- {
- Profile manager = (Profile) event.getModel();
- Date date = new Date();
- store( manager );
- manager.setCreationDate( date );
- }
- catch( Throwable e )
- {
- getLogger().error( "storage failure", e );
- }
+ getPreferences().removeNode();
+ }
+ catch( BackingStoreException e )
+ {
+ getLogger().error( "storage removal failure", e );
}
}

@@ -112,9 +102,4 @@
throw new ProfileException( error, e );
}
}
-
- protected void store( Profile profile )
- {
- throw new UnsupportedOperationException( "store/1" );
- }
}

Added:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotModelPanel.java
==============================================================================
--- (empty file)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotModelPanel.java
Mon Jun 13 20:19:39 2005
@@ -0,0 +1,309 @@
+/*
+ * 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 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.depot.profile.DepotModel;
+import net.dpml.depot.profile.ApplicationProfile;
+
+import net.dpml.transit.model.DuplicateKeyException;
+import net.dpml.transit.model.UnknownKeyException;
+
+/**
+ * Runnable plugin that handles DPML environment setup.
+ *
+ * @author <a href="mailto:mcconnell AT osm.net";>OSM</a>
+ */
+class DepotModelPanel 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 DepotModel m_model;
+ private DepotTableModel m_tableModel;
+
+ //--------------------------------------------------------------
+ // constructor
+ //--------------------------------------------------------------
+
+ public DepotModelPanel( Window parent, DepotModel model )
+ {
+ super();
+
+ m_model = model;
+ m_parent = parent;
+
+ m_editAction = new EditAction( "Edit" );
+ m_edit = new JButton( m_editAction );
+ m_delete = new JButton( new DeleteAction( "Delete" ) );
+
+ JLabel label =
+ IconHelper.createImageIconJLabel(
+ getClass().getClassLoader(), MISC_IMG_PATH,
+ "Application", "Application profiles." );
+ label.setBorder( new EmptyBorder( 0, 5, 0, 0 ) );
+ getHeader().addEntry( label, "Application Profile Registry", null );
+
+ JPanel panel = new JPanel();
+ panel.setBackground( Color.white );
+ panel.setLayout( new BorderLayout() );
+ TitledBorder tb =
+ new TitledBorder(
+ new EmptyBorder( 0,0,0,0 ), "Profiles", TitledBorder.LEFT,
TitledBorder.TOP );
+ panel.setBorder( new CompoundBorder( tb, border5 ) );
+ getBody().add( panel );
+
+ TableColumnModel columns = createProfilesColumnModel();
+ m_tableModel = new DepotTableModel( model );
+ m_table = new ClassicTable( m_tableModel, columns );
+ m_table.addPropertyChangeListener( this );
+ m_table.setShowVerticalLines( false );
+ m_table.setShowHorizontalLines( false );
+
+ JButton[] buttons = new JButton[ 3 ];
+ buttons[0] = new JButton( new AddAction( "Add" ) );
+ buttons[1] = m_edit;
+ buttons[2] = m_delete;
+ getBody().addScrollingEntry( m_table, "Application Profiles",
buttons );
+ }
+
+ public void dispose()
+ {
+ m_table.removePropertyChangeListener( this );
+ m_tableModel.dispose();
+ }
+
+ //--------------------------------------------------------------
+ // 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 )
+ {
+ try
+ {
+ ApplicationProfile profile =
m_model.getApplicationProfile( m_selection );
+ m_edit.setEnabled( true );
+ m_delete.setEnabled( true );
+ getRootPane().setDefaultButton( m_edit );
+ }
+ catch( UnknownKeyException e )
+ {
+ m_edit.setEnabled( false );
+ m_delete.setEnabled( false );
+ }
+ }
+ else
+ {
+ m_edit.setEnabled( false );
+ m_delete.setEnabled( false );
+ }
+ }
+ else if( "doubleclick".equals( event.getPropertyName() ) )
+ {
+ m_editAction.editSelection( m_edit );
+ }
+ }
+
+ //--------------------------------------------------------------
+ // utilities
+ //--------------------------------------------------------------
+
+ /**
+ * 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 createProfilesColumnModel()
+ {
+ 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( "Profile" );
+ 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 id = JOptionPane.showInputDialog( m_parent, "Application
Key:" );
+ if( null == id )
+ {
+ return;
+ }
+ //try
+ //{
+ System.out.println( "Add to " + m_model );
+ //}
+ //catch( DuplicateKeyException e )
+ //{
+ // final String error =
+ // "Unexpected error while attempting to add a new
application profile."
+ // + "\nCODEBASE: "
+ // +
getClass().getProtectionDomain().getCodeSource().getLocation().toString();
+ // m_model.getLogger().error( error, e );
+ //}
+ }
+ }
+
+ 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 = "Location Resolver";
+ //final Dimension size = new Dimension( 400, 240 );
+ //ClassicDialog dialog = ClassicDialog.createDialog(
m_parent, title, size );
+ //LayoutModel manager = m_model.getLayoutModel( m_selection
);
+ //if( null != manager )
+ //{
+ // PluginModelPanel panel =
+ // new PluginModelPanel( dialog, manager, Layout.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 profile
dialog."
+ + "\nCODEBASE: "
+ +
getClass().getProtectionDomain().getCodeSource().getLocation().toString();
+ m_model.getLogger().error( 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
+ {
+ System.out.println( "Delete: " + m_selection );
+ //LayoutModel layout = m_model.getLayoutModel( m_selection );
+ //m_model.removeLayoutModel( layout );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to delete a application
profile."
+ + "\nCODEBASE: "
+ +
getClass().getProtectionDomain().getCodeSource().getLocation().toString();
+ m_model.getLogger().error( error, e );
+ }
+ }
+ }
+
+ private static String MISC_IMG_PATH =
"net/dpml/depot/prefs/images/misc.png";
+}

Added:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotTableModel.java
==============================================================================
--- (empty file)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotTableModel.java
Mon Jun 13 20:19:39 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.depot.profile.DepotEvent;
+import net.dpml.depot.profile.DepotListener;
+import net.dpml.depot.profile.DepotModel;
+
+/**
+ * Table model that maps table rows to child nodes of a supplied preferences
node.
+ */
+public class DepotTableModel extends AbstractTableModel implements
DepotListener
+{
+
//--------------------------------------------------------------------------
+ // 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(
+ DepotTableModel.class.getClassLoader(), ICON_PATH, "Features" );
+
+ private final DepotModel m_model;
+
+
//--------------------------------------------------------------------------
+ // constructor
+
//--------------------------------------------------------------------------
+
+ /**
+ * Creation of a new table model that presents children of the supplied
preference
+ * node as table entries.
+ *
+ * @param model the registry of application profiles
+ */
+ public DepotTableModel( DepotModel model )
+ {
+ super();
+ m_model = model;
+ model.addDepotListener( this );
+ }
+
+ protected void dispose()
+ {
+ try
+ {
+ m_model.removeDepotListener( this );
+ }
+ catch( Throwable e )
+ {
+ }
+ }
+
+
//--------------------------------------------------------------------------
+ // DepotListener
+
//--------------------------------------------------------------------------
+
+ /**
+ * Notify all listeners of the addition of an application profile.
+ * @param event the depot event
+ */
+ public void profileAdded( DepotEvent event )
+ {
+ fireTableStructureChanged();
+ }
+
+ /**
+ * Notify all listeners of the removal of an application profile.
+ * @param event the depot event
+ */
+ public void profileRemoved( DepotEvent 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_model.getApplicationProfiles().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 getResolverAtRow( row );
+ }
+ }
+
+ private String getResolverAtRow( int row )
+ {
+ try
+ {
+ return m_model.getApplicationProfiles()[ row ].getID();
+ }
+ catch( Throwable e )
+ {
+ return "";
+ }
+ }
+}

Modified:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/LayoutRegistryModelPanel.java
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/LayoutRegistryModelPanel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/LayoutRegistryModelPanel.java
Mon Jun 13 20:19:39 2005
@@ -53,7 +53,6 @@
import net.dpml.transit.model.LayoutModel;
import net.dpml.transit.model.DuplicateKeyException;
import net.dpml.transit.model.UnknownKeyException;
-import net.dpml.transit.util.ExceptionHelper;

/**
* Runnable plugin that handles DPML environment setup.

Modified:
development/main/depot/station/src/main/net/dpml/depot/station/ActivationGroupProfile.java
==============================================================================
---
development/main/depot/station/src/main/net/dpml/depot/station/ActivationGroupProfile.java
(original)
+++
development/main/depot/station/src/main/net/dpml/depot/station/ActivationGroupProfile.java
Mon Jun 13 20:19:39 2005
@@ -27,8 +27,8 @@
import java.rmi.activation.ActivationGroupDesc;

import net.dpml.transit.model.Logger;
-import net.dpml.transit.home.Home;

+import net.dpml.depot.profile.ProfileHome;
import net.dpml.depot.profile.ProfileException;

/**
@@ -40,7 +40,7 @@
private CodeBaseProfile[] m_profiles;

public ActivationGroupProfile(
- Logger logger, Date creation, Home home, String id, String title,
+ Logger logger, Date creation, ProfileHome home, String id, String
title,
Properties properties, URI uri, String classname, CodeBaseProfile[]
profiles )
throws ProfileException
{

Modified:
development/main/depot/station/src/main/net/dpml/depot/station/ActivationGroupStorage.java
==============================================================================
---
development/main/depot/station/src/main/net/dpml/depot/station/ActivationGroupStorage.java
(original)
+++
development/main/depot/station/src/main/net/dpml/depot/station/ActivationGroupStorage.java
Mon Jun 13 20:19:39 2005
@@ -120,32 +120,6 @@
}

//
------------------------------------------------------------------------
- // ModificationListener
- //
------------------------------------------------------------------------
-
- /**
- * Notify a listener of a change to the manager modification date.
- * @param event the modification event
- */
- public void modified( ModificationEvent event )
- {
- if( getStoragePolicy() )
- {
- try
- {
- ActivationGroupProfile manager = (ActivationGroupProfile)
event.getModel();
- Date date = new Date();
- store( manager );
- manager.setCreationDate( date );
- }
- catch( Throwable e )
- {
- getLogger().error( "storage failure", e );
- }
- }
- }
-
- //
------------------------------------------------------------------------
// utils
//
------------------------------------------------------------------------

@@ -153,10 +127,4 @@
{
return m_profile;
}
-
- private void store( ActivationGroupProfile profile )
- {
- super.store( profile );
- throw new UnsupportedOperationException( "store/1" );
- }
}

Modified:
development/main/depot/station/src/main/net/dpml/depot/station/ActivationProfile.java
==============================================================================
---
development/main/depot/station/src/main/net/dpml/depot/station/ActivationProfile.java
(original)
+++
development/main/depot/station/src/main/net/dpml/depot/station/ActivationProfile.java
Mon Jun 13 20:19:39 2005
@@ -26,8 +26,8 @@
import java.rmi.activation.ActivationException;

import net.dpml.transit.model.Logger;
-import net.dpml.transit.home.Home;

+import net.dpml.depot.profile.ProfileHome;
import net.dpml.depot.profile.ProfileException;
import net.dpml.depot.profile.PluginProfile;

@@ -40,7 +40,7 @@
private boolean m_restart;

public ActivationProfile(
- Logger logger, Date creation, Home home, String id, String title,
+ Logger logger, Date creation, ProfileHome home, String id, String
title,
Properties properties, URI uri, String classname, boolean restart )
throws ProfileException
{

Modified:
development/main/depot/station/src/main/net/dpml/depot/station/ActivationStorage.java
==============================================================================
---
development/main/depot/station/src/main/net/dpml/depot/station/ActivationStorage.java
(original)
+++
development/main/depot/station/src/main/net/dpml/depot/station/ActivationStorage.java
Mon Jun 13 20:19:39 2005
@@ -28,7 +28,6 @@

import net.dpml.transit.model.Logger;
import net.dpml.transit.home.Home;
-import net.dpml.transit.model.ModificationEvent;

import net.dpml.depot.profile.PluginProfile;
import net.dpml.depot.profile.ProfileException;
@@ -78,40 +77,4 @@
Preferences prefs = getPreferences();
return prefs.getBoolean( "restart", true );
}
-
- //
------------------------------------------------------------------------
- // ModificationListener
- //
------------------------------------------------------------------------
-
- /**
- * Notify a listener of a change to the manager modification date.
- * @param event the modification event
- */
- public void modified( ModificationEvent event )
- {
- if( getStoragePolicy() )
- {
- try
- {
- ActivationProfile manager = (ActivationProfile)
event.getModel();
- Date date = new Date();
- store( manager );
- manager.setCreationDate( date );
- }
- catch( Throwable e )
- {
- getLogger().error( "storage failure", e );
- }
- }
- }
-
- //
------------------------------------------------------------------------
- // utils
- //
------------------------------------------------------------------------
-
- private void store( ActivationProfile profile )
- {
- super.store( profile );
- throw new UnsupportedOperationException( "store/1" );
- }
}

Modified:
development/main/depot/station/src/main/net/dpml/depot/station/CodeBaseProfile.java
==============================================================================
---
development/main/depot/station/src/main/net/dpml/depot/station/CodeBaseProfile.java
(original)
+++
development/main/depot/station/src/main/net/dpml/depot/station/CodeBaseProfile.java
Mon Jun 13 20:19:39 2005
@@ -26,10 +26,10 @@
import java.rmi.activation.ActivationException;
import java.rmi.activation.ActivationGroupDesc;

-import net.dpml.transit.home.Home;
import net.dpml.transit.model.Logger;

import net.dpml.depot.profile.Profile;
+import net.dpml.depot.profile.ProfileHome;
import net.dpml.depot.profile.ProfileException;

/**
@@ -42,7 +42,7 @@
private URI m_uri;

public CodeBaseProfile(
- Logger logger, Date creation, Home home, String id, String title,
+ Logger logger, Date creation, ProfileHome home, String id, String
title,
Properties properties, URI uri, String classname )
throws ProfileException
{

Added:
development/main/transit/core/handler/src/main/net/dpml/transit/home/Removable.java
==============================================================================
--- (empty file)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/home/Removable.java
Mon Jun 13 20:19:39 2005
@@ -0,0 +1,29 @@
+/*
+ * 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.transit.home;
+
+/**
+ * Interface implemented by removable homes.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public interface Removable
+{
+ void remove();
+}



  • svn commit: r2846 - in development/main: depot/console/src/main/net/dpml/depot depot/console/src/main/net/dpml/depot/profile depot/prefs/src/main/net/dpml/depot/prefs depot/station/src/main/net/dpml/depot/station transit/core/handler/src/main/net/dpml/transit/home, mcconnell, 06/13/2005

Archive powered by MHonArc 2.6.24.

Top of Page