Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2913 - development/main/depot/prefs/src/main/net/dpml/depot/prefs

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: r2913 - development/main/depot/prefs/src/main/net/dpml/depot/prefs
  • Date: Fri, 24 Jun 2005 12:04:41 -0400

Author: mcconnell AT dpml.net
Date: Fri Jun 24 12:04:40 2005
New Revision: 2913

Added:

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

development/main/depot/prefs/src/main/net/dpml/depot/prefs/ApplicationsRegistryPanel.java
- copied, changed from r2902,
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotModelPanel.java

development/main/depot/prefs/src/main/net/dpml/depot/prefs/ApplicationsRegistryTableModel.java
- copied, changed from r2902,
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotTableModel.java

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

development/main/depot/prefs/src/main/net/dpml/depot/prefs/ServerRegistryTableModel.java
Removed:

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

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

development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotPreferencesPanel.java
Log:
Add initial activation group profile support to prefs editor.

Added:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ActivationGroupProfilePanel.java
==============================================================================
--- (empty file)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ActivationGroupProfilePanel.java
Fri Jun 24 12:04:40 2005
@@ -0,0 +1,252 @@
+/*
+ * 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.Dimension;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.net.URI;
+import java.rmi.RemoteException;
+import java.util.Date;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.swing.AbstractAction;
+import javax.swing.BoxLayout;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+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 javax.swing.event.ListDataListener;
+import javax.swing.event.ListDataEvent;
+
+import net.dpml.depot.profile.ActivationGroupProfile;
+
+/**
+ * A interactive panel that presents the preferences for a single host.
+ *
+ * @author <a href="mailto:mcconnell AT osm.net";>Stephen McConnell</a>
+ */
+class ActivationGroupProfilePanel extends ClassicPanel
+ implements PropertyChangeListener, DocumentListener
+{
+ //--------------------------------------------------------------
+ // static
+ //--------------------------------------------------------------
+
+ static EmptyBorder border5 = new EmptyBorder( 5, 5, 5, 5);
+
+ //--------------------------------------------------------------
+ // state
+ //--------------------------------------------------------------
+
+ private final JDialog m_parent;
+ private final ActivationGroupProfile m_profile;
+
+ private JLabel m_label;
+ private JCheckBox m_enabled;
+ private JTextField m_base;
+ private JButton m_ok;
+ private JButton m_revert;
+
+ private PropertyChangeSupport m_propertyChangeSupport;
+
+ //--------------------------------------------------------------
+ // constructor
+ //--------------------------------------------------------------
+
+ public ActivationGroupProfilePanel( JDialog parent,
ActivationGroupProfile profile ) throws Exception
+ {
+ super();
+
+ m_parent = parent;
+ m_profile = profile;
+
+ //m_profile.addActivationGroupProfileListener( this );
+ m_propertyChangeSupport = new PropertyChangeSupport( this );
+
+ //
+ // create the dialog label containing the host descriptor name
+ //
+
+ String name = profile.getID();
+ m_label =
+ IconHelper.createImageIconJLabel(
+ getClass().getClassLoader(),
+ "net/dpml/depot/prefs/images/server.png", "Activation Group",
"Activation Group: " + name );
+
+ m_label.setBorder( new EmptyBorder( 0, 5, 0, 10 ) );
+ JPanel labelPanel = new JPanel();
+ labelPanel.setLayout( new BorderLayout() );
+ labelPanel.setBackground( Color.white );
+ labelPanel.add( m_label, BorderLayout.WEST );
+ labelPanel.setBorder( new EmptyBorder( 10, 6, 10, 6 ) );
+
+ //
+ // create a panel to hold things in the center of the dialog
+ //
+
+ JPanel panel = new JPanel();
+ panel.setLayout( new BoxLayout( panel, BoxLayout.Y_AXIS ) );
+ panel.setBackground( Color.white );
+
+ //
+ // add commmit/revert controls and assemble the dialog
+ //
+
+ m_ok = new JButton( new OKAction( "OK" ) );
+ m_revert = new JButton( new RevertAction( "Undo Changes" ) );
+ JPanel buttonHolder = new JPanel();
+ buttonHolder.setLayout( new FlowLayout( FlowLayout.RIGHT ) );
+ buttonHolder.add( m_revert );
+ buttonHolder.add( m_ok );
+ buttonHolder.add( new JButton( new CloseAction( "Cancel" ) ) );
+ buttonHolder.setBorder( new EmptyBorder( 10, 10, 5, 0 ) );
+ buttonHolder.setBackground( Color.white );
+
+ JPanel thing = new JPanel();
+ thing.setLayout( new BorderLayout() );
+ thing.add( panel, BorderLayout.NORTH );
+ thing.setBackground( Color.white );
+
+ add( labelPanel, BorderLayout.NORTH );
+ add( thing , BorderLayout.CENTER );
+ add( buttonHolder, BorderLayout.SOUTH );
+
+ m_propertyChangeSupport.addPropertyChangeListener( this );
+ }
+
+ public void dispose()
+ {
+ m_propertyChangeSupport.removePropertyChangeListener( this );
+ }
+
+ //--------------------------------------------------------------
+ // ActivationGroupProfileListener
+ //--------------------------------------------------------------
+
+ //--------------------------------------------------------------
+ // 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 this host.
+ */
+ public void propertyChange( PropertyChangeEvent event )
+ {
+ boolean flag = false;
+ m_ok.setEnabled( flag );
+ m_revert.setEnabled( flag );
+ }
+
+ //--------------------------------------------------------------
+ // DocumentListener
+ //--------------------------------------------------------------
+
+ public void insertUpdate( DocumentEvent event )
+ {
+ fireBaseChangedEvent();
+ }
+
+ public void removeUpdate( DocumentEvent event )
+ {
+ fireBaseChangedEvent();
+ }
+
+ public void changedUpdate( DocumentEvent event )
+ {
+ fireBaseChangedEvent();
+ }
+
+ private void fireBaseChangedEvent()
+ {
+ }
+
+ //--------------------------------------------------------------
+ // utility classes
+ //--------------------------------------------------------------
+
+ /**
+ * Action that handles the 'Cancel' dialog button.
+ */
+ private class CloseAction extends AbstractAction
+ {
+ CloseAction( String name )
+ {
+ super( name );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ m_parent.hide();
+ m_ok.setEnabled( false );
+ dispose();
+ }
+ }
+
+ private class OKAction extends AbstractAction
+ {
+ OKAction( String name )
+ {
+ super( name );
+ setEnabled( false );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ m_parent.hide();
+ dispose();
+ }
+ }
+
+ private class RevertAction extends AbstractAction
+ {
+ RevertAction( String name )
+ {
+ super( name );
+ setEnabled( false );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ PropertyChangeEvent e =
+ new PropertyChangeEvent(
+ this, "revert", null, null );
+ m_propertyChangeSupport.firePropertyChange( e );
+ }
+ }
+}

Copied:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ApplicationsRegistryPanel.java
(from r2902,
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotModelPanel.java)
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotModelPanel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ApplicationsRegistryPanel.java
Fri Jun 24 12:04:40 2005
@@ -59,7 +59,7 @@
*
* @author <a href="mailto:mcconnell AT osm.net";>OSM</a>
*/
-class DepotModelPanel extends ClassicPanel implements PropertyChangeListener
+class ApplicationsRegistryPanel extends ClassicPanel implements
PropertyChangeListener
{
//--------------------------------------------------------------
// state
@@ -74,13 +74,13 @@
private String m_selection;

private DepotProfile m_model;
- private DepotTableModel m_tableModel;
+ private ApplicationsRegistryTableModel m_tableModel;

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

- public DepotModelPanel( Window parent, DepotProfile model ) throws
Exception
+ public ApplicationsRegistryPanel( Window parent, DepotProfile model )
throws Exception
{
super();

@@ -108,7 +108,7 @@
getBody().add( panel );

TableColumnModel columns = createProfilesColumnModel();
- m_tableModel = new DepotTableModel( model );
+ m_tableModel = new ApplicationsRegistryTableModel( model );
m_table = new ClassicTable( m_tableModel, columns );
m_table.addPropertyChangeListener( this );
m_table.setShowVerticalLines( false );

Copied:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ApplicationsRegistryTableModel.java
(from r2902,
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotTableModel.java)
==============================================================================
---
development/main/depot/prefs/src/main/net/dpml/depot/prefs/DepotTableModel.java
(original)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ApplicationsRegistryTableModel.java
Fri Jun 24 12:04:40 2005
@@ -31,7 +31,7 @@
/**
* Table model that maps table rows to child nodes of a supplied preferences
node.
*/
-public class DepotTableModel extends AbstractTableModel
+public class ApplicationsRegistryTableModel extends AbstractTableModel
{

//--------------------------------------------------------------------------
// static
@@ -62,7 +62,7 @@
*/
private static final Icon FEATURE_ICON =
IconHelper.createImageIcon(
- DepotTableModel.class.getClassLoader(), ICON_PATH, "Features" );
+ ApplicationsRegistryTableModel.class.getClassLoader(), ICON_PATH,
"Features" );

private final DepotProfile m_model;
private final RemoteListener m_listener;
@@ -77,7 +77,7 @@
*
* @param model the registry of application profiles
*/
- public DepotTableModel( DepotProfile model ) throws Exception
+ public ApplicationsRegistryTableModel( DepotProfile model ) throws
Exception
{
super();
m_model = model;

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
Fri Jun 24 12:04:40 2005
@@ -84,7 +84,8 @@
private CacheModelPanel m_cachePanel;
private ContentRegistryModelPanel m_registryPanel;
private ProxyModelPanel m_proxyPanel;
- private DepotModelPanel m_depotPanel;
+ private ApplicationsRegistryPanel m_depotPanel;
+ private ServerRegistryPanel m_serverPanel;

private final Window m_window;
private final DepotProfile m_depot;
@@ -118,7 +119,7 @@
{
try
{
- m_depotPanel = new DepotModelPanel( m_window, m_depot );
+ m_depotPanel = new ApplicationsRegistryPanel( m_window,
m_depot );
tabbedPane.addTab( "Applications", m_depotPanel );
}
catch( Throwable e )
@@ -138,6 +139,26 @@
{
try
{
+ m_serverPanel = new ServerRegistryPanel( m_window,
m_depot );
+ tabbedPane.addTab( "Servers", m_serverPanel );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected during depot server panel establishment.";
+ Logger logger = Logger.getLogger( "depot.prefs" );
+ logger.log( Level.SEVERE, error, e );
+ }
+ }
+ }
+ );
+
+ SwingUtilities.invokeLater(
+ new Runnable() {
+ public void run()
+ {
+ try
+ {
final CacheModel cache = m_model.getCacheModel();
final LayoutRegistryModel layouts =
cache.getLayoutRegistryModel();
m_layoutPanel = new LayoutRegistryModelPanel( m_window,
layouts );

Added:
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ServerRegistryPanel.java
==============================================================================
--- (empty file)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ServerRegistryPanel.java
Fri Jun 24 12:04:40 2005
@@ -0,0 +1,318 @@
+/*
+ * 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.rmi.RemoteException;
+import java.util.logging.Logger;
+import java.util.logging.Level;
+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.DepotProfile;
+import net.dpml.depot.profile.ApplicationProfile;
+import net.dpml.depot.profile.ActivationGroupProfile;
+
+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 ServerRegistryPanel 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 DepotProfile m_model;
+ private ServerRegistryTableModel m_tableModel;
+
+ //--------------------------------------------------------------
+ // constructor
+ //--------------------------------------------------------------
+
+ public ServerRegistryPanel( Window parent, DepotProfile model ) throws
Exception
+ {
+ 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 ServerRegistryTableModel( 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 );
+ }
+ catch( RemoteException e )
+ {
+ final String error =
+ "Unexpected remote exception while resolving selected
application profile.";
+ throw new RuntimeException( error, e );
+ }
+ }
+ 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, "Activation
Group:" );
+ 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 = "Activation Group: " + m_selection;
+ final Dimension size = new Dimension( 400, 280 );
+ ClassicDialog dialog = ClassicDialog.createDialog( m_parent,
title, size );
+ ActivationGroupProfile profile =
m_model.getActivationGroupProfile( m_selection );
+ ActivationGroupProfilePanel panel =
+ new ActivationGroupProfilePanel( dialog, profile );
+ 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 activation
group 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
+ {
+ 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();
+ Logger logger = Logger.getLogger( "depot.prefs" );
+ logger.log( Level.SEVERE, 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/ServerRegistryTableModel.java
==============================================================================
--- (empty file)
+++
development/main/depot/prefs/src/main/net/dpml/depot/prefs/ServerRegistryTableModel.java
Fri Jun 24 12:04:40 2005
@@ -0,0 +1,211 @@
+/*
+ * 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 java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+
+import javax.swing.Icon;
+import javax.swing.table.AbstractTableModel;
+
+import net.dpml.transit.Transit;
+import net.dpml.depot.profile.DepotApplicationEvent;
+import net.dpml.depot.profile.DepotGroupEvent;
+import net.dpml.depot.profile.DepotListener;
+import net.dpml.depot.profile.DepotProfile;
+
+/**
+ * Table model that maps table rows to child nodes of a supplied preferences
node.
+ */
+public class ServerRegistryTableModel extends AbstractTableModel
+{
+
//--------------------------------------------------------------------------
+ // 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(
+ ServerRegistryTableModel.class.getClassLoader(), ICON_PATH,
"Features" );
+
+ private final DepotProfile m_model;
+ private final RemoteListener m_listener;
+
+
//--------------------------------------------------------------------------
+ // 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 ServerRegistryTableModel( DepotProfile model ) throws Exception
+ {
+ super();
+ m_model = model;
+ m_listener = new RemoteListener();
+ model.addDepotListener( m_listener );
+ }
+
+ protected void dispose()
+ {
+ try
+ {
+ m_model.removeDepotListener( m_listener );
+ }
+ catch( Throwable e )
+ {
+ }
+ }
+
+
//--------------------------------------------------------------------------
+ // DepotListener
+
//--------------------------------------------------------------------------
+
+ private class RemoteListener extends UnicastRemoteObject implements
DepotListener
+ {
+ public RemoteListener() throws RemoteException
+ {
+ super();
+ }
+
+ /**
+ * Notify all listeners of the addition of an application profile.
+ * @param event the depot event
+ */
+ public void profileAdded( DepotApplicationEvent event ) throws
RemoteException
+ {
+ }
+
+ /**
+ * Notify all listeners of the removal of an application profile.
+ * @param event the depot event
+ */
+ public void profileRemoved( DepotApplicationEvent event ) throws
RemoteException
+ {
+ }
+
+ /**
+ * Notify all listeners of the addition of an application profile.
+ * @param event the depot event
+ */
+ public void groupAdded( DepotGroupEvent event ) throws
RemoteException
+ {
+ fireTableStructureChanged();
+ }
+
+ /**
+ * Notify all listeners of the removal of an application profile.
+ * @param event the depot event
+ */
+ public void groupRemoved( DepotGroupEvent event ) throws
RemoteException
+ {
+ 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.getActivationGroupProfiles().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.getActivationGroupProfiles()[ row ].getID();
+ }
+ catch( Throwable e )
+ {
+ return "";
+ }
+ }
+}



  • svn commit: r2913 - development/main/depot/prefs/src/main/net/dpml/depot/prefs, mcconnell, 06/24/2005

Archive powered by MHonArc 2.6.24.

Top of Page