Skip to Content.
Sympa Menu

notify-dpml - svn commit: r1350 - in development/laboratory/mgr: . main/src/main/net/dpml/mgr/feature main/src/main/net/dpml/mgr/main main/src/main/net/dpml/mgr/provider plugins/home/src/main/net/dpml/mgr/home plugins/magic/src/main/net/dpml/mgr/magic plugins/metro/src/main/net/dpml/mgr/metro plugins/transit/src/main/net/dpml/mgr/transit

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT netcompartner.com
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r1350 - in development/laboratory/mgr: . main/src/main/net/dpml/mgr/feature main/src/main/net/dpml/mgr/main main/src/main/net/dpml/mgr/provider plugins/home/src/main/net/dpml/mgr/home plugins/magic/src/main/net/dpml/mgr/magic plugins/metro/src/main/net/dpml/mgr/metro plugins/transit/src/main/net/dpml/mgr/transit
  • Date: Mon, 03 Jan 2005 06:49:13 +0100

Author: mcconnell
Date: Mon Jan 3 06:49:13 2005
New Revision: 1350

Added:
development/laboratory/mgr/main/src/main/net/dpml/mgr/feature/

development/laboratory/mgr/main/src/main/net/dpml/mgr/feature/ActiveFeature.java
(contents, props changed)

development/laboratory/mgr/main/src/main/net/dpml/mgr/feature/DefaultCellRenderer.java
(contents, props changed)

development/laboratory/mgr/main/src/main/net/dpml/mgr/feature/FeatureTableModel.java
(contents, props changed)

development/laboratory/mgr/main/src/main/net/dpml/mgr/feature/FeaturesBuilder.java
(contents, props changed)

development/laboratory/mgr/main/src/main/net/dpml/mgr/feature/StaticFeature.java
(contents, props changed)
development/laboratory/mgr/main/src/main/net/dpml/mgr/feature/package.html
(contents, props changed)

development/laboratory/mgr/main/src/main/net/dpml/mgr/main/StandardTable.java
(contents, props changed)
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/package.html
(contents, props changed)

development/laboratory/mgr/main/src/main/net/dpml/mgr/provider/Desktop.java
(contents, props changed)

development/laboratory/mgr/main/src/main/net/dpml/mgr/provider/DesktopException.java
(contents, props changed)

development/laboratory/mgr/main/src/main/net/dpml/mgr/provider/FeatureProvider.java
(contents, props changed)

development/laboratory/mgr/main/src/main/net/dpml/mgr/provider/package.html
(contents, props changed)
development/laboratory/mgr/module.xml (contents, props changed)
development/laboratory/mgr/overview.html (contents, props changed)

development/laboratory/mgr/plugins/home/src/main/net/dpml/mgr/home/package.html
(contents, props changed)
Removed:

development/laboratory/mgr/main/src/main/net/dpml/mgr/main/ActiveFeature.java

development/laboratory/mgr/main/src/main/net/dpml/mgr/main/DefaultCellRenderer.java
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/DefaultTab.java
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/Desktop.java

development/laboratory/mgr/main/src/main/net/dpml/mgr/main/DesktopException.java

development/laboratory/mgr/main/src/main/net/dpml/mgr/main/FeatureTableModel.java

development/laboratory/mgr/main/src/main/net/dpml/mgr/main/FeaturesPanel.java
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/ListTab.java
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/ScrollView.java
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/TablePanel.java
Modified:
development/laboratory/mgr/index.xml

development/laboratory/mgr/main/src/main/net/dpml/mgr/main/DefaultDesktop.java

development/laboratory/mgr/main/src/main/net/dpml/mgr/main/DefaultMenuBar.java

development/laboratory/mgr/main/src/main/net/dpml/mgr/main/HideWindowAction.java

development/laboratory/mgr/main/src/main/net/dpml/mgr/main/PropertiesDialog.java

development/laboratory/mgr/main/src/main/net/dpml/mgr/main/PropertiesTabbedPane.java

development/laboratory/mgr/main/src/main/net/dpml/mgr/provider/PropertyHandler.java

development/laboratory/mgr/plugins/home/src/main/net/dpml/mgr/home/HomeComponent.java

development/laboratory/mgr/plugins/magic/src/main/net/dpml/mgr/magic/MagicComponent.java

development/laboratory/mgr/plugins/metro/src/main/net/dpml/mgr/metro/MetroComponent.java

development/laboratory/mgr/plugins/transit/src/main/net/dpml/mgr/transit/TransitComponent.java
Log:
Get feature tables into a reasonably complete state.

Modified: development/laboratory/mgr/index.xml
==============================================================================
--- development/laboratory/mgr/index.xml (original)
+++ development/laboratory/mgr/index.xml Mon Jan 3 06:49:13 2005
@@ -23,6 +23,20 @@

<import uri="artifact:module:dpml/metro/dpml-metro#SNAPSHOT"/>

+
+ <project file="module.xml">
+ <info>
+ <group>dpml/mgr</group>
+ <name>dpml-mgr</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ <type>module</type>
+ </info>
+ <plugins>
+ <include key="dpml-magic-checkstyle"/>
+ </plugins>
+ </project>
+
<project basedir="main">
<info>
<group>dpml/mgr</group>
@@ -46,6 +60,10 @@
<name>dpml-mgr-home</name>
<type>jar</type>
</info>
+ <dependencies>
+ <include key="dpml-mgr-main"/>
+ <include key="dpml-transit-main"/>
+ </dependencies>
</project>

<project basedir="plugins/transit">

Added:
development/laboratory/mgr/main/src/main/net/dpml/mgr/feature/ActiveFeature.java
==============================================================================
--- (empty file)
+++
development/laboratory/mgr/main/src/main/net/dpml/mgr/feature/ActiveFeature.java
Mon Jan 3 06:49:13 2005
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2004 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.mgr.feature;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.NoSuchMethodException;
+import java.lang.IllegalAccessException;
+import java.lang.reflect.Method;
+
+import net.dpml.mgr.provider.Feature;
+
+/**
+ * A <code>ActiveFeature</code> is a name value pair container that
+ * exposed the name of a property event that can be used to monitor the
+ * feature value.
+ */
+public class ActiveFeature implements Feature
+{
+
//--------------------------------------------------------------------------
+ // state
+
//--------------------------------------------------------------------------
+
+ /**
+ * The entity holding the feature.
+ */
+ private Object entity;
+
+ /**
+ * Name of the feature.
+ */
+ private String name;
+
+ /**
+ * The name of the property to monitor.
+ */
+ String property;
+
+ /**
+ * The name of the operation to invoke.
+ */
+ String operation;
+
+ /**
+ * The method to invoke.
+ */
+ Method method;
+
+
//--------------------------------------------------------------------------
+ // Constructor
+
//--------------------------------------------------------------------------
+
+ /**
+ * The <code>ActiveFeature</code> class supports association of a
+ * named value pair and exposed a property event name that can be used
+ * to monitor feature value changes.
+ *
+ * @param entity the entity holding the feature
+ * @param name the name of the feature
+ * @param operation the feature accessor
+ * @param property the name of the property change event associated with
the feature
+ */
+ public ActiveFeature( Object entity, String name, String operation,
String property )
+ {
+ this.name = name;
+ this.entity = entity;
+ this.operation = operation;
+ this.property = property;
+ try
+ {
+ method = entity.getClass().getMethod( operation, new Class[0] );
+ }
+ catch( Exception e )
+ {
+ throw new RuntimeException("ActiveFeature, Argument error.",
e );
+ }
+ }
+
+
//--------------------------------------------------------------------------
+ // Feature
+
//--------------------------------------------------------------------------
+
+ public String getName()
+ {
+ return this.name;
+ }
+
+ /**
+ * Invokes a method on an object based on a supplied target object and a
keyword. The
+ * implementation prepends the keyword with the 'get' string, and
capatilizes the first
+ * character of the keyword (as per the Java Beans convention).
+ */
+ public Object getValue()
+ {
+ try
+ {
+ return method.invoke( entity, new Object[0] );
+ }
+ catch( Exception e )
+ {
+ throw new RuntimeException("ActiveFeature, unexpected
invocation problem.", e );
+ }
+ }
+
+
//--------------------------------------------------------------------------
+ // ActiveFeature
+
//--------------------------------------------------------------------------
+
+ /**
+ * Return the property name for this feature.
+ */
+ public String getPropertyName( )
+ {
+ return property;
+ }
+}

Added:
development/laboratory/mgr/main/src/main/net/dpml/mgr/feature/DefaultCellRenderer.java
==============================================================================
--- (empty file)
+++
development/laboratory/mgr/main/src/main/net/dpml/mgr/feature/DefaultCellRenderer.java
Mon Jan 3 06:49:13 2005
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2004 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.mgr.feature;
+
+import java.awt.Component;
+import java.awt.Font;
+import javax.swing.ImageIcon;
+import javax.swing.JCheckBox;
+import javax.swing.JLabel;
+import javax.swing.JTable;
+import javax.swing.SwingConstants;
+import javax.swing.border.EmptyBorder;
+import javax.swing.table.DefaultTableCellRenderer;
+
+import net.dpml.mgr.provider.Desktop;
+
+class DefaultCellRenderer extends DefaultTableCellRenderer
+{
+
//--------------------------------------------------------------------------
+ // state
+
//--------------------------------------------------------------------------
+
+ private static final EmptyBorder border = new EmptyBorder(1,5,1,3);
+
+ private Font font;
+
+
//--------------------------------------------------------------------------
+ // constructor
+
//--------------------------------------------------------------------------
+
+ /**
+ * Creation of a new cell renderer using the default font.
+ */
+ public DefaultCellRenderer( )
+ {
+ this( Desktop.DEFAULT_FONT );
+ }
+
+ /**
+ * Creation of a new cell renderer using a supplied font.
+ * @param font the default font to use when rendering components
+ */
+ public DefaultCellRenderer( Font font )
+ {
+ this.font = font;
+ }
+
+
//--------------------------------------------------------------------------
+ // implementation
+
//--------------------------------------------------------------------------
+
+ public Component getTableCellRendererComponent(
+ JTable table, Object object, boolean selected, boolean focus, int row,
int column )
+ {
+ JLabel label =
+ (JLabel) super.getTableCellRendererComponent(
+ table, object, selected, focus, row, column );
+ label.setBorder( border );
+ label.setFont( font );
+ label.setHorizontalAlignment( SwingConstants.LEFT );
+
+ if( object == null )
+ {
+ label.setIcon( null );
+ label.setText( null );
+ return label;
+ }
+
+ if( object instanceof ImageIcon )
+ {
+ label.setText( null );
+ label.setIcon( (ImageIcon) object );
+ return label;
+ }
+ else if( object instanceof Boolean )
+ {
+ JCheckBox checkBox = new JCheckBox();
+ checkBox.setSelected( ((Boolean)object).booleanValue() );
+ if( selected )
+ {
+ checkBox.setForeground(table.getSelectionForeground());
+ checkBox.setBackground(table.getSelectionBackground());
+ }
+ else
+ {
+ checkBox.setForeground(table.getForeground());
+ checkBox.setBackground(table.getBackground());
+ }
+ checkBox.setBorder( new EmptyBorder(0,20,0,10) );
+ checkBox.setHorizontalAlignment(JCheckBox.LEFT);
+ return checkBox;
+ }
+ else
+ {
+ return label;
+ }
+ }
+}
+

Added:
development/laboratory/mgr/main/src/main/net/dpml/mgr/feature/FeatureTableModel.java
==============================================================================
--- (empty file)
+++
development/laboratory/mgr/main/src/main/net/dpml/mgr/feature/FeatureTableModel.java
Mon Jan 3 06:49:13 2005
@@ -0,0 +1,234 @@
+/*
+ * Copyright 2004 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.mgr.feature;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeEvent;
+import java.util.Arrays;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Iterator;
+import java.net.URL;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+
+import net.dpml.mgr.provider.Feature;
+import net.dpml.mgr.provider.FeatureProvider;
+
+/**
+ * Table model used to manage features of an adapter.
+ */
+class FeatureTableModel extends AbstractTableModel implements
PropertyChangeListener
+{
+
//--------------------------------------------------------------------------
+ // static
+
//--------------------------------------------------------------------------
+
+ /**
+ * Default small icon path.
+ */
+ private static final String FEATURE_ICON_PATH =
"/net/dpml/mgr/images/feature.gif";
+
+ /**
+ * Constant row identifier for the icon.
+ */
+ public static final int ICON = 0;
+
+ /**
+ * Constant row identifier for the name.
+ */
+ public static final int NAME = 1;
+
+ /**
+ * Constant row identifier for the name.
+ */
+ public static final int VALUE = 2;
+
+ /**
+ * Number of columns.
+ */
+ private static final int COLUMN_COUNT = 3;
+
+ /**
+ * Default small icon.
+ */
+ private static final Icon FEATURE_ICON = createImageIcon(
FEATURE_ICON_PATH );
+
+
//--------------------------------------------------------------------------
+ // state
+
//--------------------------------------------------------------------------
+
+ /**
+ * The features list.
+ */
+ private List m_features;
+
+ /**
+ * The reference entity.
+ */
+ private Object m_entity;
+
+
//--------------------------------------------------------------------------
+ // constructor
+
//--------------------------------------------------------------------------
+
+ /**
+ * Creation of a new feature table model.
+ * @param entity the reference entity
+ */
+ public FeatureTableModel ( Object entity )
+ {
+ super();
+ m_entity = entity;
+ if( entity instanceof FeatureProvider )
+ {
+ m_features = Arrays.asList( ( (FeatureProvider) entity
).getFeatures() );
+ }
+ else
+ {
+ m_features = new LinkedList();
+ }
+ //entity.addPropertyChangeListener( this );
+ }
+
+
//--------------------------------------------------------------------------
+ // PropertyChangeListener
+
//--------------------------------------------------------------------------
+
+ /**
+ * Property event change handler that handles a property change event
+ * from an entity backing a particular feature.
+ * @param event the property change event
+ */
+ public void propertyChange( PropertyChangeEvent event )
+ {
+ int n = locate( event.getPropertyName() );
+ if( n > -1 )
+ {
+ fireTableCellUpdated( n, VALUE );
+ }
+ }
+
+ /**
+ * Locate the position of an active feature in the list.
+ * @param key the property name
+ * @return the row holding the named feature
+ */
+ private int locate( String key )
+ {
+ int n = 0;
+ Iterator iterator = m_features.iterator();
+ while( iterator.hasNext() )
+ {
+ Object object = iterator.next();
+ if( object instanceof ActiveFeature )
+ {
+ if( ( (ActiveFeature) object ).getPropertyName().equals( key
) )
+ {
+ return n;
+ }
+ }
+ n++;
+ }
+ return -1;
+ }
+
+
//--------------------------------------------------------------------------
+ // FeatureTableModel
+
//--------------------------------------------------------------------------
+
+ /**
+ * 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()
+ {
+ return m_features.size();
+ }
+
+ /**
+ * 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 = "";
+ Feature feature = getFeature( row );
+ if( feature != null )
+ {
+ switch( col )
+ {
+ case ICON :
+ return FEATURE_ICON;
+ case NAME :
+ return feature.getName();
+ case VALUE :
+ return feature.getValue();
+ default:
+ return m_entity;
+ }
+ }
+ else
+ {
+ return result;
+ }
+ }
+
+ /**
+ * Returns an instance of feature given a supplied row.
+ * @param row the row in the feature list
+ * @return the feature
+ */
+ private Feature getFeature( int row )
+ {
+ return (Feature) m_features.get( row );
+ }
+
+ /**
+ * Create an image icon relative to a supplied resource path.
+ * @param path the icon resource path
+ * @return the image icon
+ */
+ private static ImageIcon createImageIcon( String path )
+ {
+ URL url = FeatureTableModel.class.getResource( path );
+ if( null != url )
+ {
+ return new ImageIcon( url, "Feature" );
+ }
+ else
+ {
+ System.err.println( "Couldn't find feature icon on path: " +
path );
+ return null;
+ }
+ }
+}

Added:
development/laboratory/mgr/main/src/main/net/dpml/mgr/feature/FeaturesBuilder.java
==============================================================================
--- (empty file)
+++
development/laboratory/mgr/main/src/main/net/dpml/mgr/feature/FeaturesBuilder.java
Mon Jan 3 06:49:13 2005
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2004 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.mgr.feature;
+
+import java.awt.Font;
+import java.util.LinkedList;
+import javax.swing.JTable;
+import javax.swing.table.TableModel;
+import javax.swing.table.TableColumnModel;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.ListSelectionModel;
+import javax.swing.table.TableColumn;
+import javax.swing.table.DefaultTableColumnModel;
+import javax.swing.table.DefaultTableModel;
+
+import net.dpml.mgr.main.StandardTable;
+import net.dpml.mgr.provider.Desktop;
+
+/**
+ * A panel presenting entities in the form of a table.
+ */
+public class FeaturesBuilder
+{
+
//--------------------------------------------------------------------------
+ // static
+
//--------------------------------------------------------------------------
+
+ /**
+ * Utility method to construct a parameterized feature table.
+ * @param entity the reference entity
+ * @return the table
+ */
+ public static JTable createFeaturesTable( Object entity )
+ {
+ TableColumnModel columns = newFeaturesColumnModel(
Desktop.DEFAULT_FONT );
+ FeatureTableModel model = new FeatureTableModel( entity );
+ return createFeaturesTable( entity, model, columns );
+ }
+
+ /**
+ * Utility method to construct a parameterized feature table.
+ * @param entity the reference entity
+ * @param model the table model
+ * @param columns the column model
+ * @return the table
+ */
+ public static JTable createFeaturesTable( Object entity, TableModel
model, TableColumnModel columns )
+ {
+ return new StandardTable( entity, model, columns );
+ }
+
+ /**
+ * Utility method to construct a parameterized column model.
+ * @param font the font
+ * @return the table
+ */
+ private static TableColumnModel newFeaturesColumnModel( Font font )
+ {
+ //
+ // create a column model
+ //
+
+ TableColumn iconColumn = new TableColumn( 0, 30, new
DefaultCellRenderer( font ), null );
+ iconColumn.setHeaderValue("");
+ iconColumn.setMaxWidth( 30 );
+ iconColumn.setMinWidth( 30 );
+
+ TableColumn nameColumn = new TableColumn( 1, 100, new
DefaultCellRenderer( font ), null );
+ nameColumn.setHeaderValue("Name");
+ TableColumn valueColumn = new TableColumn( 2, 210, new
DefaultCellRenderer( font ), null );
+ valueColumn.setHeaderValue("Value");
+
+ TableColumnModel columnModel = new DefaultTableColumnModel();
+ columnModel.addColumn( iconColumn );
+ columnModel.addColumn( nameColumn );
+ columnModel.addColumn( valueColumn );
+
+ return columnModel;
+ }
+
+ /**
+ * Null constructor.
+ */
+ private FeaturesBuilder()
+ {
+ }
+}

Added:
development/laboratory/mgr/main/src/main/net/dpml/mgr/feature/StaticFeature.java
==============================================================================
--- (empty file)
+++
development/laboratory/mgr/main/src/main/net/dpml/mgr/feature/StaticFeature.java
Mon Jan 3 06:49:13 2005
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2004 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.mgr.feature;
+
+import net.dpml.mgr.provider.Feature;
+
+/**
+ * A <code>StaticFeature</code> is an immutable named-value pair.
+ */
+public class StaticFeature implements Feature
+{
+
+ /**
+ * Feature name.
+ */
+ private final String m_name;
+
+ /**
+ * Feature value.
+ */
+ private final Object m_value;
+
+
//------------------------------------------------------------------------
+ // Constructor
+
//------------------------------------------------------------------------
+
+ /**
+ * The <code>StaticFeature</code> class supports association of a named
value pair.
+ * @param name the name of the feature
+ * @param value the value of the feature
+ */
+ public StaticFeature( final String name, final Object value )
+ {
+ m_name = name;
+ m_value = value;
+ }
+
+
//------------------------------------------------------------------------
+ // Feature
+
//------------------------------------------------------------------------
+
+ /**
+ * Return the feature name.
+ * @return the name
+ */
+ public String getName()
+ {
+ return m_name;
+ }
+
+ /**
+ * Return the feature value.
+ * @return the value
+ */
+ public Object getValue()
+ {
+ return m_value;
+ }
+}

Added:
development/laboratory/mgr/main/src/main/net/dpml/mgr/feature/package.html
==============================================================================
--- (empty file)
+++
development/laboratory/mgr/main/src/main/net/dpml/mgr/feature/package.html
Mon Jan 3 06:49:13 2005
@@ -0,0 +1,6 @@
+
+<body>
+<p>
+Resources supporting the presentation of named-value pairs as a table model.
+</p>
+</body>

Modified:
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/DefaultDesktop.java
==============================================================================
---
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/DefaultDesktop.java
(original)
+++
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/DefaultDesktop.java
Mon Jan 3 06:49:13 2005
@@ -16,74 +16,83 @@

package net.dpml.mgr.main;

-import java.awt.Font;
-import java.awt.Toolkit;
-import java.awt.Dimension;
import java.awt.Component;
import java.awt.Color;
import java.awt.FlowLayout;
-import java.awt.Container;
-import java.awt.Window;
import java.awt.Frame;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JLabel;
-import javax.swing.JMenu;
import javax.swing.JMenuItem;
-import javax.swing.JMenuBar;
-import javax.swing.JDesktopPane;
-import javax.swing.KeyStroke;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.AbstractButton;
-import javax.swing.JComponent;
import javax.swing.JPopupMenu;
import java.awt.event.ActionListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
import java.awt.event.ActionEvent;
-import java.awt.event.KeyEvent;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
-import java.awt.event.MouseListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.net.URI;
import java.net.URL;
-import java.util.Map;
-import java.util.Hashtable;

import net.dpml.activity.Startable;
-import net.dpml.composition.model.ContainmentModel;
import net.dpml.configuration.Configuration;
import net.dpml.configuration.ConfigurationException;
-import net.dpml.context.Context;
-import net.dpml.context.ContextException;
import net.dpml.logging.Logger;
import net.dpml.transit.repository.Repository;
import net.dpml.transit.repository.StandardLoader;
-import net.dpml.transit.util.Dictionary;
+
+import net.dpml.mgr.provider.Desktop;
+import net.dpml.mgr.provider.DesktopException;

/**
* The desktop shell manages the presentation of root panel and menubar.
* @metro.component name="desktop" lifestyle="singleton"
- * @metro.service type="net.dpml.mgr.main.Desktop"
+ * @metro.service type="net.dpml.mgr.provider.Desktop"
*/
public class DefaultDesktop extends JFrame
- implements Startable, Runnable, Desktop, ActionListener, FocusListener
+ implements Startable, Runnable, Desktop, ActionListener
{

//--------------------------------------------------------------------------
// static

//--------------------------------------------------------------------------

- public static Font DEFAULT_FONT = new Font("Dialog", 0, 11);
-
+ /**
+ * Declare the default look-and-feel as active.
+ */
static
{
JFrame.setDefaultLookAndFeelDecorated( true );
}

+ /**
+ * The default frame width.
+ */
+ private static final int DEFAULT_FRAME_WIDTH = 700;
+
+ /**
+ * The default frame height.
+ */
+ private static final int DEFAULT_FRAME_HEIGHT = 500;
+
+ /**
+ * The default button width.
+ */
+ private static final int DEFAULT_BUTTON_WIDTH = 200;
+
+ /**
+ * The default button height.
+ */
+ private static final int DEFAULT_BUTTON_HEIGHT = 35;
+
+ /**
+ * The right-click key id.
+ */
+ private static final int RIGHT_CLICK_BUTTON_ID = 3;
+

//--------------------------------------------------------------------------
// state

//--------------------------------------------------------------------------
@@ -108,13 +117,17 @@

//--------------------------------------------------------------------------

/**
+ * Creation of a new desktop manager.
+ * @param logger the logging channel
+ * @param config the desktop configuration
+ * @exception Exception if an instantiation error occurs
*/
public DefaultDesktop( Logger logger, Configuration config )
throws Exception
{
- if( logger.isDebugEnabled() )
+ if( logger.isDebugEnabled() )
{
- logger.debug("desktop initialization");
+ logger.debug( "desktop initialization" );
}
m_logger = logger;
m_configuration = config;
@@ -125,12 +138,19 @@
// Startable

//--------------------------------------------------------------------------

+ /**
+ * Start the component during which a rich-client interface is
established.
+ */
public void start()
{
Thread thread = new Thread( this );
thread.start();
}

+ /**
+ * Stop the component. This implementation currently calls System.exit
and should
+ * be replaced by a shutdown facility.
+ */
public void stop()
{
System.exit( 0 );
@@ -140,6 +160,11 @@
// Runnable

//--------------------------------------------------------------------------

+ /**
+ * Runnable implementation that handles initialization of the desktop
interface.
+ * Current implementation has no error handling - pending the
introduction of
+ * an error handling facility within metro.
+ */
public void run()
{
try
@@ -156,36 +181,26 @@
// ActionListener

//--------------------------------------------------------------------------

- public void actionPerformed(ActionEvent e)
+ /**
+ * Action listener that handles desktop menu events.
+ * @param event the action event
+ */
+ public void actionPerformed( ActionEvent event )
{
- if( "quit".equals( e.getActionCommand() ) )
+ if( "quit".equals( event.getActionCommand() ) )
{
exit( 0 );
}
}


//--------------------------------------------------------------------------
- // FocusListener
-
//--------------------------------------------------------------------------
-
- public void focusGained( FocusEvent event )
- {
- System.out.println( "# GAINED" );
- }
-
- public void focusLost( FocusEvent event )
- {
- System.out.println( "# LOST" );
- }
-
-
-
//--------------------------------------------------------------------------
// implementation

//--------------------------------------------------------------------------

/**
* Setup the root panel including creation of a menubar, scrollpane,
* and intial content based on the supplied configuration.
+ * @exception DesktopException if an initialization error occurs
*/
private void initialize() throws DesktopException
{
@@ -201,7 +216,7 @@

JPanel panel = new JPanel();
panel.setBackground( Color.white );
- panel.setSize( 700, 500 );
+ panel.setSize( DEFAULT_FRAME_WIDTH, DEFAULT_FRAME_HEIGHT );
panel.setLayout( new FlowLayout( FlowLayout.LEFT ) );
panel.addMouseListener( new BackgroundListener() );
panel.setFocusCycleRoot( true );
@@ -212,7 +227,7 @@

Configuration conf = m_configuration.getChild( "desktop" );
Configuration[] entries = conf.getChildren( "entry" );
- for( int i=0; i<entries.length; i++ )
+ for( int i=0; i < entries.length; i++ )
{
Configuration entry = entries[i];
URI uri = getEntryURI( entry );
@@ -240,12 +255,17 @@
setTitle( "MGR" );
DefaultMenuBar menubar = new DefaultMenuBar( DEFAULT_FONT, this );
setJMenuBar( menubar );
- setSize( 700, 500 );
- //addWindowListener( new WindowHandler( this ) );
+ setSize( DEFAULT_FRAME_WIDTH, DEFAULT_FRAME_HEIGHT );
setVisible( true );
-
}

+ /**
+ * Return the uri attribute from the supplied configuration fragment.
+ * @param entry the configuration entry element
+ * @return the artifact uri
+ * @exception DesktopException if a configuration or attribute value
+ * interpritation error occurs
+ */
private URI getEntryURI( Configuration entry ) throws DesktopException
{
try
@@ -267,29 +287,44 @@
}
}

+ /**
+ * Create a iconic button representing the supplied uri using the
supplied title.
+ * The implementation creates a new JButton instance and associates to
this
+ * a focus and mouse listener associated with the plugin referenced by
the supplied
+ * uri.
+ *
+ * @param uri an artifact uri
+ * @param title the button title
+ * @return the iconic representation of the uri object
+ * @exception DesktopException if a plugin instantiation error occurs
+ */
private Component constructDesktopIcon( final URI uri, final String
title )
throws DesktopException
{
- Class component = getPluginClass( uri );
- ImageIcon icon = createImageIcon( component );
-
+ Object entity = getPlugin( uri );
+ ImageIcon icon = createImageIcon( entity.getClass() );
JButton button = new JButton( title, icon );

button.setVerticalTextPosition( JLabel.BOTTOM );
button.setHorizontalTextPosition( JLabel.CENTER );
button.setFont( DEFAULT_FONT );
button.setBackground( Color.white );
- button.setSize( 200, 35 );
+ button.setSize( DEFAULT_BUTTON_WIDTH, DEFAULT_BUTTON_HEIGHT );

button.setBorderPainted( false );
button.setFocusPainted( false );
button.setContentAreaFilled( false );
button.addFocusListener( new FocusHandler() );
- button.addMouseListener( new ClickListener( this ) );
+ button.addMouseListener( new ClickListener( this, entity ) );

return button;
}

+ /**
+ * Creation of the image icon used in creation of a desktop button.
+ * @param clazz the plugin class
+ * @return the image icon
+ */
protected static ImageIcon createImageIcon( Class clazz )
{
String path = "/" + clazz.getName().replace( '.', '/' ) + ".icon";
@@ -300,11 +335,40 @@
}
else
{
- System.err.println("Couldn't find icon on path: " + path);
+ System.err.println( "Couldn't find icon on path: " + path );
return null;
}
}

+ /**
+ * Load a plugin using a supplied artifact uri.
+ * @param uri the plugin uri
+ * @return the plugin instance
+ * @exception DesktopException if a plugin loading error occurs
+ */
+ private Object getPlugin( URI uri ) throws DesktopException
+ {
+ try
+ {
+ ClassLoader classloader = DefaultDesktop.class.getClassLoader();
+ return m_repository.getPlugin( classloader, uri, new Object[0] );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "An error occured while attempting to load a desktop plugin ["
+ + uri.toString()
+ + "].";
+ throw new DesktopException( error, e );
+ }
+ }
+
+ /**
+ * Get the plugin class (not used)
+ * @param uri the plugin uri
+ * @return the plugin class
+ * @exception DesktopException if a plugin class loading error occurs
+ */
private Class getPluginClass( URI uri ) throws DesktopException
{
try
@@ -322,11 +386,19 @@
}
}

+ /**
+ * Exit the session.
+ * @param status the exit status
+ */
private void exit( int status )
{
stop();
}

+ /**
+ * Return the assigned logging channel.
+ * @return the logging channel
+ */
private Logger getLogger()
{
return m_logger;
@@ -339,11 +411,18 @@
*/
private static class BackgroundListener extends MouseAdapter
{
+ /**
+ * Handle a mouse pressed event in the desktop background. The
+ * implementation triggers a focus request and checks for a
+ * right-button click in which case a context menu is presented.
+ *
+ * @param event the mouse event
+ */
public void mousePressed( MouseEvent event )
{
Component component = event.getComponent();
component.requestFocus();
- if( event.getButton() == 3 )
+ if( event.getButton() == RIGHT_CLICK_BUTTON_ID )
{
//
// present a popup menu
@@ -368,13 +447,38 @@
*/
private static class ClickListener extends MouseAdapter implements
ActionListener
{
+ /**
+ * The parent frame used as the anchor window when constructing a
+ * a properties dialog.
+ */
private final Frame m_parent;

- ClickListener( Frame parent )
+ /**
+ * The object backing the widget.
+ */
+ private final Object m_entity;
+
+ /**
+ * Creation of a new mouse click listener that is used to monitor
+ * mouse events associated with buttons present in the desktop content
+ * panel.
+ *
+ * @param parent the parent frame
+ * @param entity the reference object
+ */
+ ClickListener( Frame parent, Object entity )
{
m_parent = parent;
+ m_entity = entity;
}

+ /**
+ * Handle a mouseclick associated with the reference entity. The
+ * implementation checks for double-click and right-click events
+ * and in the case of the later prepares a pop-up context menu.
+ *
+ * @param event the mouse event
+ */
public void mouseClicked( MouseEvent event )
{
Component component = event.getComponent();
@@ -383,7 +487,7 @@
{
System.out.println( "# double-click" );
}
- else if( event.getButton() == 3 )
+ else if( event.getButton() == RIGHT_CLICK_BUTTON_ID )
{
//
// create a popup context menu
@@ -402,6 +506,13 @@
}
}

+ /**
+ * Creation of a new popup menu item.
+ * @param label the menu item label
+ * @param key the menu item key
+ * @param enabled the enabled state of the menu item
+ * @return the new menu item
+ */
private JMenuItem createJMenuItem( String label, String key, boolean
enabled )
{
JMenuItem item = new JMenuItem( label );
@@ -412,17 +523,21 @@
return item;
}

- public void actionPerformed(ActionEvent e)
+ /**
+ * Handle an action for the popup menu.
+ * @param event the action event
+ */
+ public void actionPerformed( ActionEvent event )
{
- if( "properties".equals( e.getActionCommand() ) )
+ if( "properties".equals( event.getActionCommand() ) )
{
PropertiesDialog dialog =
- new PropertiesDialog( m_parent, "Properties" );
+ new PropertiesDialog( m_parent, m_entity, "Properties" );
dialog.setVisible( true );
}
else
{
- System.out.println( "ACTION: " + e.getActionCommand() );
+ System.out.println( "ACTION: " + event.getActionCommand() );
}
}
}
@@ -433,18 +548,29 @@
*/
private static class FocusHandler implements FocusListener
{
+ /**
+ * Handle a focus gained event under which we update the visual
+ * presentation of the source desktop button to indicate current
+ * keyboard focus.
+ * @param event the focus event
+ */
public void focusGained( FocusEvent event )
{
Component component = event.getComponent();
- ((AbstractButton)component).setBorderPainted( true );
+ ( (AbstractButton) component ).setBorderPainted( true );
}

+ /**
+ * Handle a focus lost event under which we update the visual
+ * presentation of the source desktop button.
+ * @param event the focus event
+ */
public void focusLost( FocusEvent event )
{
if( !event.isTemporary() )
{
Component component = event.getComponent();
- ((AbstractButton)component).setBorderPainted( false );
+ ( (AbstractButton) component ).setBorderPainted( false );
}
}
}

Modified:
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/DefaultMenuBar.java
==============================================================================
---
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/DefaultMenuBar.java
(original)
+++
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/DefaultMenuBar.java
Mon Jan 3 06:49:13 2005
@@ -21,7 +21,6 @@
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
-import javax.swing.AbstractAction;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JMenu;
@@ -35,6 +34,11 @@
// constructor

//--------------------------------------------------------------------------

+ /**
+ * Creation of a new menubar.
+ * @param font the font
+ * @param listener the action listener
+ */
public DefaultMenuBar( Font font, ActionListener listener )
{
//
@@ -42,7 +46,7 @@
//

JMenu file = new JMenu( "File" );
- file.setMnemonic(KeyEvent.VK_F);
+ file.setMnemonic( KeyEvent.VK_F );
file.setFont( font );
add( file );

@@ -52,7 +56,7 @@

JMenuItem quit = new JMenuItem( "Quit" );
quit.setFont( font );
- quit.setMnemonic(KeyEvent.VK_Q);
+ quit.setMnemonic( KeyEvent.VK_Q );
quit.setAccelerator(
KeyStroke.getKeyStroke(
KeyEvent.VK_Q, ActionEvent.ALT_MASK ) );

Modified:
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/HideWindowAction.java
==============================================================================
---
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/HideWindowAction.java
(original)
+++
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/HideWindowAction.java
Mon Jan 3 06:49:13 2005
@@ -33,7 +33,10 @@
// state

//--------------------------------------------------------------------------

- private Component source;
+ /**
+ * The source component.
+ */
+ private Component m_source;


//--------------------------------------------------------------------------
// constructor
@@ -41,11 +44,14 @@

/**
* Default constructor.
+ * @param name the action name
+ * @param source the source component from which the containing frame is
+ * resolved
*/
public HideWindowAction( String name, Component source )
{
super( name );
- this.source = source;
+ m_source = source;
}


//--------------------------------------------------------------------------
@@ -54,20 +60,35 @@

/**
* Called when the cancel button is trigged.
+ * @param event the action event
*/
public void actionPerformed( ActionEvent event )
{
- if( event.getSource() == source )
+ if( event.getSource() == m_source )
{
- JDialog dialog = getDialog( source );
- if( dialog != null ) dialog.setVisible( false );
+ JDialog dialog = getDialog( m_source );
+ if( dialog != null )
+ {
+ dialog.setVisible( false );
+ }
}
}

+ /**
+ * Resolve the enclosing dialog relative to a target component.
+ * @param component the source component
+ * @return the containing dialog
+ */
private static JDialog getDialog( Component component )
{
- if( component instanceof JDialog ) return (JDialog) component;
- return (JDialog) SwingUtilities.getAncestorOfClass( JDialog.class,
component);
+ if( component instanceof JDialog )
+ {
+ return (JDialog) component;
+ }
+ else
+ {
+ return (JDialog) SwingUtilities.getAncestorOfClass(
JDialog.class, component );
+ }
}

}

Modified:
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/PropertiesDialog.java
==============================================================================
---
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/PropertiesDialog.java
(original)
+++
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/PropertiesDialog.java
Mon Jan 3 06:49:13 2005
@@ -17,18 +17,18 @@
package net.dpml.mgr.main;

import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.Dimension;
+import java.awt.BorderLayout;
import javax.swing.JDialog;
import javax.swing.JButton;
import javax.swing.Action;
import javax.swing.JPanel;
import javax.swing.BoxLayout;
import javax.swing.Box;
-import java.awt.Frame;
-import java.awt.Dimension;
-import java.awt.BorderLayout;

/**
- * The default menubar implementation.
+ * Implementation of a properties dialog.
*/
class PropertiesDialog extends JDialog
{
@@ -36,26 +36,47 @@
// static

//--------------------------------------------------------------------------

+ /**
+ * Declare the default look and feel as current.
+ */
static
{
JDialog.setDefaultLookAndFeelDecorated( true );
}

+ /**
+ * The default dialog width.
+ */
+ private static final int DEFAULT_DIALOG_WIDTH = 400;
+
+ /**
+ * The default dialog height.
+ */
+ private static final int DEFAULT_DIALOG_HEIGHT = 450;
+

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

//--------------------------------------------------------------------------

- public PropertiesDialog( Frame parent, String title )
+ /**
+ * Creation of a new properties dialog using a supplied anchor frame,
+ * adapter, and window title.
+ * @param parent the parent frame against which the dialog box will be
anchored
+ * @param entity the reference component
+ * @param title the dialog title
+ */
+ public PropertiesDialog( Frame parent, Object entity, String title )
{
super( parent, title );
- Dimension size = new Dimension( 400, 450 );
+
+ Dimension size = new Dimension( DEFAULT_DIALOG_WIDTH,
DEFAULT_DIALOG_HEIGHT );
setSize( size );

//
// Create a tabbed pane
//

- PropertiesTabbedPane tabbedPane = new PropertiesTabbedPane( parent );
+ PropertiesTabbedPane tabbedPane = new PropertiesTabbedPane( entity );


//
@@ -72,7 +93,7 @@

cancel.setAction( cancelAction );
apply.setAction( applyAction );
- applyAction.setEnabled( false );
+ applyAction.setEnabled( false );
ok.setAction( okAction );

JPanel buttonPanel = new JPanel( new FlowLayout( FlowLayout.RIGHT )
);
@@ -90,8 +111,8 @@
holder.add( tabbedPane, BorderLayout.CENTER );
holder.add( buttonHolder, BorderLayout.SOUTH );

- setContentPane( holder );
- setSize( size );
+ setContentPane( holder );
+ setSize( size );
setLocationRelativeTo( parent );
getRootPane().setDefaultButton( ok );


Modified:
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/PropertiesTabbedPane.java
==============================================================================
---
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/PropertiesTabbedPane.java
(original)
+++
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/PropertiesTabbedPane.java
Mon Jan 3 06:49:13 2005
@@ -16,20 +16,20 @@

package net.dpml.mgr.main;

+import java.awt.Color;
import java.awt.FlowLayout;
-import java.awt.Frame;
-import java.awt.Dimension;
import java.awt.BorderLayout;
import java.awt.Component;
import javax.swing.JDialog;
-import javax.swing.JButton;
+import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
-import javax.swing.Action;
import javax.swing.JPanel;
-import javax.swing.BoxLayout;
-import javax.swing.Box;
+import javax.swing.JLabel;
import javax.swing.border.EmptyBorder;

+import net.dpml.mgr.provider.Desktop;
+import net.dpml.mgr.feature.FeaturesBuilder;
+
/**
* The default menubar implementation.
*/
@@ -39,28 +39,104 @@
// static

//--------------------------------------------------------------------------

+ /**
+ * Declare the default look and feel.
+ */
static
{
JDialog.setDefaultLookAndFeelDecorated( true );
}

+ /**
+ * Empty boarder offset.
+ */
+ private static final int OFFSET = 10;
+
+ /**
+ * Empty boarder offset.
+ */
+ private static final int LEAD = 20;
+
+ /**
+ * Null offsey
+ */
+ private static final int ZERO = 0;
+

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

//--------------------------------------------------------------------------

- public PropertiesTabbedPane( Frame parent )
+ /**
+ * Creation of a new properties tab pane.
+ * @param entity the reference entity
+ */
+ public PropertiesTabbedPane( Object entity )
{
super();
- setBorder( new EmptyBorder( 20, 10, 10, 10 ));
- setFont( DefaultDesktop.DEFAULT_FONT );
+ setBorder( new EmptyBorder( LEAD, OFFSET, OFFSET, OFFSET ) );
+ setFont( Desktop.DEFAULT_FONT );
+
+ Component features = FeaturesBuilder.createFeaturesTable( entity );
+ JScrollPane scroller = createScrollPanel( features );
+ JPanel holder = createNamedPanel( "Features", scroller );
+
+ addTab( "Features", holder );
+ }
+
+ /**
+ * 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_AS_NEEDED );
+ scroller.getViewport().setBackground( Color.white );
+ scroller.setViewportView( view );
+ return scroller;
+ }
+
+ /**
+ * Creation of a panel containing a section in which a name banner is
presented.
+ * @param name the name to assign
+ * @param view the properties content view
+ * @return the panel containing a name header and property content view
+ */
+ private static JPanel createNamedPanel( final String name, Component
view )
+ {
+ JPanel panel = createNamedPanel( name );
+ JPanel holder = new JPanel( new BorderLayout() );
+ holder.setBorder( new EmptyBorder( ZERO, OFFSET, OFFSET, OFFSET ) );
+ holder.add( view, BorderLayout.CENTER );
+ panel.add( holder );
+ return panel;
+ }
+
+ /**
+ * Create the panel holding a name.
+ * @param name the name to assign
+ * @return the panel containing the name as a label
+ */
+ private static JPanel createNamedPanel( final String name )
+ {
+ JPanel panel = new JPanel();
+ panel.setLayout( new BorderLayout() );

- Component featuresTab =
- new ListTab("Features",
- new ScrollView(
- new FeaturesPanel( parent, "Features",
DefaultDesktop.DEFAULT_FONT )
- )
- );
+ //
+ // Create the header holding the panel name
+ //
+
+ JLabel label = new JLabel( name );
+ label.setFont( Desktop.DEFAULT_FONT );
+ label.setBorder( new EmptyBorder( OFFSET, OFFSET, OFFSET, OFFSET ) );
+ JPanel labelHolder = new JPanel( new FlowLayout( FlowLayout.LEFT ) );
+ labelHolder.add( label );
+ panel.add( labelHolder, BorderLayout.NORTH );

- addTab( "Features", featuresTab );
+ return panel;
}
}

Added:
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/StandardTable.java
==============================================================================
--- (empty file)
+++
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/StandardTable.java
Mon Jan 3 06:49:13 2005
@@ -0,0 +1,229 @@
+/*
+ * Copyright 2004 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.mgr.main;
+
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.Color;
+import javax.swing.JTable;
+import javax.swing.table.TableModel;
+import javax.swing.table.TableColumnModel;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.ListSelectionModel;
+import javax.swing.SwingUtilities;
+
+
+/**
+ * A panel presenting entities in the form of a table.
+ */
+public class StandardTable extends JTable implements ListSelectionListener,
FocusListener
+{
+
//--------------------------------------------------------------------------
+ // static
+
//--------------------------------------------------------------------------
+
+ /**
+ * The enabled color.
+ */
+ private static final Color ENABLED_COLOR = new Color( 204, 204, 255 );
+
+ /**
+ * The disabled color.
+ */
+ private static final Color DISABLED_COLOR = new Color( 228, 228, 255 );
+
+ /**
+ * Double-click count.
+ */
+ private static final int TWO = 2;
+
+ /**
+ * Row height.
+ */
+ private static final int ROW_HEIGHT = 22;
+
+
//--------------------------------------------------------------------------
+ // state
+
//--------------------------------------------------------------------------
+
+ /**
+ * The entity that this table is referencing.
+ */
+ private Object m_entity;
+
+ /**
+ * The currently selected item if only 1 instance is selected.
+ */
+ private Object m_selection;
+
+ /**
+ * The table data model.
+ */
+ private TableModel m_data;
+
+
//--------------------------------------------------------------------------
+ // constructor
+
//--------------------------------------------------------------------------
+
+ /**
+ * Creation of a new StandardTable.
+ * @param entity the entity that this table is presenting
+ * @param data a table model containing the data to layout in view
+ * @param columns the table column model to apply
+ */
+ public StandardTable( Object entity, TableModel data, TableColumnModel
columns )
+ {
+ super( data, columns );
+
+ if( entity == null )
+ {
+ throw new NullPointerException( "entity" );
+ }
+
+ m_data = data;
+ m_entity = entity;
+
+ setShowGrid( false );
+ setRowHeight( ROW_HEIGHT );
+ getTableHeader().setReorderingAllowed( false );
+
+ MouseListener popupListener = new PopupListener();
+ addMouseListener( popupListener );
+ addFocusListener( this );
+ }
+
+
//--------------------------------------------------------------------------
+ // ListSelectionListener
+
//--------------------------------------------------------------------------
+
+ /**
+ * Listens to changes in the selected state of the table and
+ * propergates a <code>ContextEvent</code> referencing this table as
+ * the event's panel when the table selection changes.
+ * @param event a list selection event
+ */
+ public void valueChanged( ListSelectionEvent event )
+ {
+ super.valueChanged( event );
+ if( !event.getValueIsAdjusting() )
+ {
+ ListSelectionModel model = getSelectionModel();
+ synchronized( model )
+ {
+ int n = model.getMinSelectionIndex();
+ if( ( n == model.getMaxSelectionIndex() ) && ( n > -1 ) )
+ {
+ m_selection = m_data.getValueAt( n, -1 );
+ }
+ else if( m_selection != null )
+ {
+ m_selection = null;
+ }
+ }
+ }
+ }
+
+
//--------------------------------------------------------------------------
+ // FocusListener
+
//--------------------------------------------------------------------------
+
+ /**
+ * Handle the focus gained event.
+ * @param event the focus event
+ */
+ public void focusGained( FocusEvent event )
+ {
+ setSelectionBackground( ENABLED_COLOR );
+ }
+
+ /**
+ * Handle the focus lost event.
+ * @param event the focus event
+ */
+ public void focusLost( FocusEvent event )
+ {
+ setSelectionBackground( DISABLED_COLOR );
+ }
+
+ /**
+ * Handle a mouse event within the table.
+ * @param event the mouse event
+ */
+ protected void handleMouseEvent( MouseEvent event )
+ {
+ if( event.isPopupTrigger() )
+ {
+ int j = rowAtPoint( event.getPoint() );
+ if( j > -1 )
+ {
+ if( !isRowSelected( j ) )
+ {
+ clearSelection();
+ setRowSelectionInterval( j, j );
+ }
+ }
+ else
+ {
+ clearSelection();
+ }
+ }
+ else if( SwingUtilities.isLeftMouseButton( event ) &&
event.getClickCount() == TWO )
+ {
+ int j = rowAtPoint( event.getPoint() );
+ if( j > -1 )
+ {
+ if( !isRowSelected( j ) )
+ {
+ clearSelection();
+ setRowSelectionInterval( j, j );
+ }
+ }
+ else
+ {
+ clearSelection();
+ }
+ }
+ }
+
+ /**
+ * Mouse adapter.
+ */
+ private class PopupListener extends MouseAdapter
+ {
+ /**
+ * Handle a mouse event.
+ * @param event the mouse pressed event
+ */
+ public void mousePressed( MouseEvent event )
+ {
+ handleMouseEvent( event );
+ }
+
+ /**
+ * Handle a mouse event.
+ * @param event the mouse released event
+ */
+ public void mouseReleased( MouseEvent event )
+ {
+ handleMouseEvent( event );
+ }
+ }
+}

Added: development/laboratory/mgr/main/src/main/net/dpml/mgr/main/package.html
==============================================================================
--- (empty file)
+++ development/laboratory/mgr/main/src/main/net/dpml/mgr/main/package.html
Mon Jan 3 06:49:13 2005
@@ -0,0 +1,6 @@
+
+<body>
+<p>
+Principal application component.
+</p>
+</body>

Added:
development/laboratory/mgr/main/src/main/net/dpml/mgr/provider/Desktop.java
==============================================================================
--- (empty file)
+++
development/laboratory/mgr/main/src/main/net/dpml/mgr/provider/Desktop.java
Mon Jan 3 06:49:13 2005
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2004 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.mgr.provider;
+
+import java.awt.event.ActionListener;
+import java.awt.Font;
+
+/**
+ * The desktop shell manages the presentation of a menubar, working
+ * panels and status bar.
+ */
+public interface Desktop extends ActionListener
+{
+ /**
+ * The default font name.
+ */
+ String DEFAULT_FONT_NAME = "Dialog";
+
+ /**
+ * The default font size.
+ */
+ int DEFAULT_FONT_SIZE = 11;
+
+ /**
+ * The default font.
+ */
+ Font DEFAULT_FONT = new Font( DEFAULT_FONT_NAME, 0, DEFAULT_FONT_SIZE );
+}

Added:
development/laboratory/mgr/main/src/main/net/dpml/mgr/provider/DesktopException.java
==============================================================================
--- (empty file)
+++
development/laboratory/mgr/main/src/main/net/dpml/mgr/provider/DesktopException.java
Mon Jan 3 06:49:13 2005
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2004 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.mgr.provider;
+
+/**
+ * General desktop exception.
+ */
+public class DesktopException extends Exception
+{
+
//--------------------------------------------------------------------------
+ // constructor
+
//--------------------------------------------------------------------------
+
+ /**
+ * New desktop exception constructor.
+ * @param message the exception message
+ */
+ public DesktopException( String message )
+ {
+ this( message, null );
+ }
+
+ /**
+ * New desktop exception constructor.
+ * @param message the exception message
+ * @param cause the causal exception
+ */
+ public DesktopException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+}

Added:
development/laboratory/mgr/main/src/main/net/dpml/mgr/provider/FeatureProvider.java
==============================================================================
--- (empty file)
+++
development/laboratory/mgr/main/src/main/net/dpml/mgr/provider/FeatureProvider.java
Mon Jan 3 06:49:13 2005
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2004 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.mgr.provider;
+
+/**
+ * The contract implementated by components that expose features.
+ */
+public interface FeatureProvider
+{
+ /**
+ * Return the set of features provided by the implementation.
+ * @return the sequence of features
+ */
+ Feature[] getFeatures();
+}

Modified:
development/laboratory/mgr/main/src/main/net/dpml/mgr/provider/PropertyHandler.java
==============================================================================
---
development/laboratory/mgr/main/src/main/net/dpml/mgr/provider/PropertyHandler.java
(original)
+++
development/laboratory/mgr/main/src/main/net/dpml/mgr/provider/PropertyHandler.java
Mon Jan 3 06:49:13 2005
@@ -24,5 +24,9 @@
*/
public interface PropertyHandler
{
+ /**
+ * Returns the set of property panels provided by the implementation.
+ * @return the component array
+ */
Component[] getPropertyPanels();
}

Added:
development/laboratory/mgr/main/src/main/net/dpml/mgr/provider/package.html
==============================================================================
--- (empty file)
+++
development/laboratory/mgr/main/src/main/net/dpml/mgr/provider/package.html
Mon Jan 3 06:49:13 2005
@@ -0,0 +1,6 @@
+
+<body>
+<p>
+Provider interfaces to the MGR framework.
+</p>
+</body>

Added: development/laboratory/mgr/module.xml
==============================================================================
--- (empty file)
+++ development/laboratory/mgr/module.xml Mon Jan 3 06:49:13 2005
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-mgr" default="install" basedir="."
+ xmlns:magic="antlib:net.dpml.magic"
+ xmlns:x="plugin:dpml/magic/dpml-magic-core">
+
+ <magic:import uri="artifact:template:dpml/magic/standard"/>
+ <magic:import uri="artifact:template:dpml/magic/checkstyle"/>
+
+ <target name="build" depends="standard.build">
+ <x:module index="index.xml"/>
+ </target>
+
+ <target name="install" depends="standard.install,docs"/>
+
+ <target name="docs" depends="standard.install,junit-report,checkstyle">
+ <x:javadoc overview="overview.html" title="DPML MGR API -
${project.version}">
+ <link href="http://java.sun.com/j2se/1.4/docs/api"/>
+ </x:javadoc>
+ </target>
+
+ <target name="junit-report" depends="test">
+ <mkdir dir="target/reports/junit"/>
+ <junitreport todir="target/reports/junit">
+ <fileset dir=".">
+ <include name="**/target/test-reports/TEST-*.xml"/>
+ </fileset>
+ <report format="frames" todir="target/reports/junit"/>
+ </junitreport>
+ </target>
+
+</project>

Added: development/laboratory/mgr/overview.html
==============================================================================
--- (empty file)
+++ development/laboratory/mgr/overview.html Mon Jan 3 06:49:13 2005
@@ -0,0 +1,7 @@
+<body>
+
+<p>
+The MGR package is a component-based rich-client framework.
+</p>
+
+</body>
\ No newline at end of file

Modified:
development/laboratory/mgr/plugins/home/src/main/net/dpml/mgr/home/HomeComponent.java
==============================================================================
---
development/laboratory/mgr/plugins/home/src/main/net/dpml/mgr/home/HomeComponent.java
(original)
+++
development/laboratory/mgr/plugins/home/src/main/net/dpml/mgr/home/HomeComponent.java
Mon Jan 3 06:49:13 2005
@@ -16,15 +16,36 @@

package net.dpml.mgr.home;

-import java.awt.Component;
+import net.dpml.mgr.provider.Feature;
+import net.dpml.mgr.provider.FeatureProvider;
+import net.dpml.mgr.feature.StaticFeature;
+
+import net.dpml.transit.Transit;
+

/**
- * The home component is a model of the DPML Home.
- *
+ * The home adapter is a model of the DPML Home.
*/
-public class HomeComponent extends Component
+public class HomeComponent implements FeatureProvider
{
- public HomeComponent()
+ /**
+ * The name feature.
+ */
+ private static final Feature NAME =
+ new StaticFeature( "name", "DPML System Home" );
+
+ /**
+ * The home directory feature.
+ */
+ private static final Feature HOME =
+ new StaticFeature( "dpml.home", Transit.DPML_HOME.getAbsolutePath() );
+
+ /**
+ * Return all of the features exposed by this adapter.
+ * @return the feature sequence
+ */
+ public Feature[] getFeatures()
{
+ return new Feature[]{NAME, HOME};
}
}

Added:
development/laboratory/mgr/plugins/home/src/main/net/dpml/mgr/home/package.html
==============================================================================
--- (empty file)
+++
development/laboratory/mgr/plugins/home/src/main/net/dpml/mgr/home/package.html
Mon Jan 3 06:49:13 2005
@@ -0,0 +1,6 @@
+
+<body>
+<p>
+DPML Home agent.
+</p>
+</body>

Modified:
development/laboratory/mgr/plugins/magic/src/main/net/dpml/mgr/magic/MagicComponent.java
==============================================================================
---
development/laboratory/mgr/plugins/magic/src/main/net/dpml/mgr/magic/MagicComponent.java
(original)
+++
development/laboratory/mgr/plugins/magic/src/main/net/dpml/mgr/magic/MagicComponent.java
Mon Jan 3 06:49:13 2005
@@ -16,12 +16,10 @@

package net.dpml.mgr.magic;

-import java.awt.Component;
-
/**
- * The home component is a model of the DPML Home.
+ * The magic adapter.
*
*/
-public class MagicComponent extends Component
+public class MagicComponent
{
}

Modified:
development/laboratory/mgr/plugins/metro/src/main/net/dpml/mgr/metro/MetroComponent.java
==============================================================================
---
development/laboratory/mgr/plugins/metro/src/main/net/dpml/mgr/metro/MetroComponent.java
(original)
+++
development/laboratory/mgr/plugins/metro/src/main/net/dpml/mgr/metro/MetroComponent.java
Mon Jan 3 06:49:13 2005
@@ -16,12 +16,10 @@

package net.dpml.mgr.metro;

-import java.awt.Component;
-
/**
- * The home component is a model of the DPML Home.
+ * The metro adapter.
*
*/
-public class MetroComponent extends Component
+public class MetroComponent
{
}

Modified:
development/laboratory/mgr/plugins/transit/src/main/net/dpml/mgr/transit/TransitComponent.java
==============================================================================
---
development/laboratory/mgr/plugins/transit/src/main/net/dpml/mgr/transit/TransitComponent.java
(original)
+++
development/laboratory/mgr/plugins/transit/src/main/net/dpml/mgr/transit/TransitComponent.java
Mon Jan 3 06:49:13 2005
@@ -16,15 +16,10 @@

package net.dpml.mgr.transit;

-import java.awt.Component;
-
/**
- * The home component is a model of the DPML Home.
+ * The transit adapter.
*
*/
-public class TransitComponent extends Component
+public class TransitComponent
{
- public TransitComponent()
- {
- }
}



  • svn commit: r1350 - in development/laboratory/mgr: . main/src/main/net/dpml/mgr/feature main/src/main/net/dpml/mgr/main main/src/main/net/dpml/mgr/provider plugins/home/src/main/net/dpml/mgr/home plugins/magic/src/main/net/dpml/mgr/magic plugins/metro/src/main/net/dpml/mgr/metro plugins/transit/src/main/net/dpml/mgr/transit, mcconnell, 01/03/2005

Archive powered by MHonArc 2.6.24.

Top of Page