commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly maven.xml
Date Mon, 30 Sep 2002 17:52:28 GMT
jstrachan    2002/09/30 10:52:28

  Modified:    jelly/src/java/org/apache/commons/jelly/tags/swing
                        SwingTagLibrary.java
               jelly    maven.xml
  Added:       jelly/src/test/org/apache/commons/jelly/swing
                        showVariables.jelly
               jelly/src/java/org/apache/commons/jelly/tags/swing/model
                        ExpressionTableModel.java
                        ExpressionTableColumn.java package.html
               jelly/src/java/org/apache/commons/jelly/tags/swing
                        TableModelTag.java TableModelColumnTag.java
  Log:
  Added support in JellySwing for simple TableModels which use any pluggable Jelly Expressions
for defining the columns.
  
  This allows any List of objects to be easily rendered in a table in JellySwing without any
programming involved. Its hoped this kind of thing could be ported to SWT too!
  
  A simple example has been added which will display all the variables in the current context
in a table.
  This could be improved somewhat, but shows that a List of property names can be displayed
in a table, showing the value, type, row index and the name of the variable; all powered by
a List of Strings.
  
  Another good demo could be to render a table of beans (such as some Maven POM objects) in
a table.
  Or to use commons-beanutils or commons-sql to get some DynaBeans and render those in a table
using expressions.
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/swing/showVariables.jelly
  
  Index: showVariables.jelly
  ===================================================================
  <?xml version="1.0"?>
  <j:jelly 
  	xmlns:j="jelly:core" 
  	xmlns="jelly:swing" 
  	xmlns:log="jelly:log">
  
  	<!-- lets create the model -->
  	<j:useList var="list" items="${context.getVariableNames()}"/>
  
  	<log:info>Created list ${list}</log:info>
  		
  	<!-- create the dialog -->
  	<dialog var="dialog" size="400,150" location="200,200" title="Variables">
  		<scrollPane>
    		<table>
  				<tableModel rows="${list}">
  					<tableModelColumn headerValue="ID" value="${rowIndex}"/>
  					<tableModelColumn headerValue="Name" value="${row}"/>
  					<tableModelColumn headerValue="Value" value="${context.getVariable(row)}"/>
  					<tableModelColumn headerValue="Type" value="${context.getVariable(row).getClass().getName()}"/>
  				</tableModel>
      	</table>
      </scrollPane>
  	</dialog>
  
  	${dialog.setVisible(true)}
  
  </j:jelly>
  
  
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/swing/model/ExpressionTableModel.java
  
  Index: ExpressionTableModel.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/define/DynamicTag.java,v
1.7 2002/05/17 15:18:12 jstrachan Exp $
   * $Revision: 1.7 $
   * $Date: 2002/05/17 15:18:12 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: DynamicTag.java,v 1.7 2002/05/17 15:18:12 jstrachan Exp $
   */
  package org.apache.commons.jelly.tags.swing.model;
  
  import java.util.ArrayList;
  import java.util.List;
  import javax.swing.table.AbstractTableModel;
  import javax.swing.table.DefaultTableColumnModel;
  import javax.swing.table.TableColumnModel;
  
  import org.apache.commons.jelly.JellyContext;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /** 
   * A Swing TableModel that uses a List of rows with pluggable Expressions 
   * to evaluate the value of the cells
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.7 $
   */
  public class ExpressionTableModel extends AbstractTableModel {
  
      private JellyContext context;
      private List rows = new ArrayList();
      private MyTableColumnModel columnModel = new MyTableColumnModel();
          
      public ExpressionTableModel() {
      }
      
      /**
       * Returns the column definitions.
       * @return List
       */
      public List getColumnList() {
          return columnModel.getColumnList();
      }
  
      /**
       * @return the TableColumnModel
       */
      public TableColumnModel getColumnModel() {
          return columnModel;
      }
      
      /**
       * Adds a new column definition to the table
       */
      public void addColumn(ExpressionTableColumn column) {
          columnModel.addColumn(column);
      }
  
      /**
       * Removes a column definition from the table
       */
      public void removeColumn(ExpressionTableColumn column) {
          columnModel.removeColumn(column);
      }
      
      
      // TableModel interface
      //-------------------------------------------------------------------------  
      public int getRowCount() {
          return rows.size();
      }
      
      public int getColumnCount() {
          return columnModel.getColumnCount();
      }
      
      public String getColumnName(int columnIndex) {
          String answer = null;
          if (columnIndex < 0 || columnIndex >= columnModel.getColumnCount()) {
              return answer;
          }
          Object value = columnModel.getColumn(columnIndex).getHeaderValue();
          if (value != null) {
              return value.toString();
          }
          return answer;
      }
      
      public Object getValueAt(int rowIndex, int columnIndex) {
          Object answer = null;
          if (rowIndex < 0 || rowIndex >= rows.size()) {
              return answer;
          }
          if (columnIndex < 0 || columnIndex >= columnModel.getColumnCount()) {
              return answer;
          }
          Object row = rows.get(rowIndex);;
          ExpressionTableColumn column = (ExpressionTableColumn) columnModel.getColumn(columnIndex);
          if (row == null || column == null) {
              return answer;
          }
          return column.evaluateValue(this, row, rowIndex, columnIndex);
      }
  
  
      // Properties
      //-------------------------------------------------------------------------        
           
      
      
      /**
       * Returns the list of rows.
       * @return List
       */
      public List getRows() {
          return rows;
      }
  
      /**
       * Sets the list of rows.
       * @param rows The rows to set
       */
      public void setRows(List rows) {
          this.rows = rows;
      }
  
      /**
       * Returns the context.
       * @return JellyContext
       */
      public JellyContext getContext() {
          return context;
      }
  
      /**
       * Sets the context.
       * @param context The context to set
       */
      public void setContext(JellyContext context) {
          this.context = context;
      }
      
      // Implementation methods
      //-------------------------------------------------------------------------        
           
      protected static class MyTableColumnModel extends DefaultTableColumnModel {
          public List getColumnList() {
              return tableColumns;
          }
      };
          
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/swing/model/ExpressionTableColumn.java
  
  Index: ExpressionTableColumn.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/define/DynamicTag.java,v
1.7 2002/05/17 15:18:12 jstrachan Exp $
   * $Revision: 1.7 $
   * $Date: 2002/05/17 15:18:12 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: DynamicTag.java,v 1.7 2002/05/17 15:18:12 jstrachan Exp $
   */
  package org.apache.commons.jelly.tags.swing.model;
  
  import javax.swing.table.TableColumn;
  
  import org.apache.commons.jelly.JellyContext;
  import org.apache.commons.jelly.expression.Expression;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /** 
   * Represents a column in an ExpressionTable
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.7 $
   */
  public class ExpressionTableColumn extends TableColumn {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog( ExpressionTableColumn.class );
      
      private Expression value;
      private Class type = Object.class;
      
      public ExpressionTableColumn() {
      }
  
      public String toString() {
          return super.toString() + "[value:" + value + "]";
      }
      
      /**
       * Evaluates the value of a cell
       */    
      public Object evaluateValue(ExpressionTableModel model, Object row, int rowIndex, int
columnIndex) {
          if (value == null) {
              return null;
          }
          // lets put the values in the context
          JellyContext context = model.getContext();
          context.setVariable("rows", model.getRows());
          context.setVariable("columns", model.getColumnList());
          context.setVariable("row", row);
          context.setVariable("rowIndex", new Integer(rowIndex));
          context.setVariable("columnIndex", new Integer(columnIndex));
          
          // now lets invoke the expression
          try {
              return value.evaluateRecurse(context);
          }
          catch (RuntimeException e) {
              log.warn( "Caught exception: " + e + " evaluating: " + value, e );
              throw e;
          }
      }
  
      // Properties
      //-------------------------------------------------------------------------        
           
      
      /**
       * Returns the column type.
       * @return Class
       */
      public Class getType() {
          return type;
      }
  
      /**
       * Returns the expression used to extract the value.
       * @return Expression
       */
      public Expression getValue() {
          return value;
      }
  
      /**
       * Sets the expression used to extract the value.
       * @param type The type to set
       */
      public void setType(Class type) {
          this.type = type;
      }
  
      /**
       * Sets the value.
       * @param value The value to set
       */
      public void setValue(Expression value) {
          this.value = value;
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/swing/model/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  </head>
  <body>
  
    <p>
    	Swing model implementations that can be used with JellySwing
    </p>
    
  </body>
  </html>
  
  
  
  1.11      +5 -0      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/swing/SwingTagLibrary.java
  
  Index: SwingTagLibrary.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/swing/SwingTagLibrary.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SwingTagLibrary.java	26 Sep 2002 18:07:36 -0000	1.10
  +++ SwingTagLibrary.java	30 Sep 2002 17:52:27 -0000	1.11
  @@ -114,6 +114,11 @@
           registerTag( "action", ActionTag.class );
           registerTag( "font", FontTag.class );
           registerTag( "windowListener", WindowListenerTag.class );
  +
  +        
  +        // the model tags
  +        registerTag( "tableModel", TableModelTag.class );
  +        registerTag( "tableModelColumn", TableModelColumnTag.class );
           
           // the border tags...
           registerTag( "titledBorder", TitledBorderTag.class );
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/swing/TableModelTag.java
  
  Index: TableModelTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/define/DynamicTag.java,v
1.7 2002/05/17 15:18:12 jstrachan Exp $
   * $Revision: 1.7 $
   * $Date: 2002/05/17 15:18:12 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: DynamicTag.java,v 1.7 2002/05/17 15:18:12 jstrachan Exp $
   */
  package org.apache.commons.jelly.tags.swing;
  
  import javax.swing.JTable;
  import javax.swing.table.TableModel;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.tags.core.UseBeanTag;
  import org.apache.commons.jelly.tags.swing.model.ExpressionTableModel;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /** 
   * Creates a default TableModel using nested tableColumn tags.
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.7 $
   */
  public class TableModelTag extends UseBeanTag {
  
      public ExpressionTableModel getTableModel() {
          return (ExpressionTableModel) getBean();
      }    
          
  
      // Implementation methods
      //-------------------------------------------------------------------------        
           
      protected void processBean(String var, Object bean) throws Exception {
          super.processBean(var, bean);
  
          ComponentTag tag = (ComponentTag) findAncestorWithClass( ComponentTag.class );
          if ( tag == null ) {
              throw new JellyException( "This tag must be nested within a JellySwing <table>
tag" );
          }
          ExpressionTableModel model = getTableModel();
          model.setContext(context);
          
          Object component = tag.getComponent();
          if (component instanceof JTable) {
              JTable table = (JTable) component;
              table.setModel(model);
          }
          else {
              throw new JellyException( "This tag must be nested within a JellySwing <table>
tag" );
          }
      }
      
      protected Class getDefaultClass() {
          return ExpressionTableModel.class;
      }
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/swing/TableModelColumnTag.java
  
  Index: TableModelColumnTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/define/DynamicTag.java,v
1.7 2002/05/17 15:18:12 jstrachan Exp $
   * $Revision: 1.7 $
   * $Date: 2002/05/17 15:18:12 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: DynamicTag.java,v 1.7 2002/05/17 15:18:12 jstrachan Exp $
   */
  package org.apache.commons.jelly.tags.swing;
  
  import javax.swing.table.TableColumn;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.expression.Expression;
  import org.apache.commons.jelly.tags.core.UseBeanTag;
  import org.apache.commons.jelly.tags.swing.model.ExpressionTableColumn;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /** 
   * Creates a default TableColumnModel.
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.7 $
   */
  public class TableModelColumnTag extends UseBeanTag {
  
      public ExpressionTableColumn getColumn() {
          return (ExpressionTableColumn) getBean();
      }    
          
      public Class getAttributeType(String name) throws Exception {
          if (name.equals("value")) {
              return Expression.class;
          }
          return super.getAttributeType(name);
      }
  
      // Implementation methods
      //-------------------------------------------------------------------------        
           
      protected void processBean(String var, Object bean) throws Exception {
          super.processBean(var, bean);
  
          TableModelTag tag = (TableModelTag) findAncestorWithClass( TableModelTag.class );
          if ( tag == null ) {
              throw new JellyException( "This tag must be nested within a <tableModel>
tag" );
          }
          tag.getTableModel().addColumn( getColumn() );
      }
      
      protected Class getDefaultClass() {
          return ExpressionTableColumn.class;
      }
  }
  
  
  
  
  1.36      +11 -1     jakarta-commons-sandbox/jelly/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/maven.xml,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- maven.xml	27 Sep 2002 02:12:31 -0000	1.35
  +++ maven.xml	30 Sep 2002 17:52:28 -0000	1.36
  @@ -470,5 +470,15 @@
        <arg value="src/test/org/apache/commons/jelly/swing/run.jelly"/> 
       </java>
     </goal>
  -	
  +
  +	<!-- a simple example program to demonstrate the use of <tableModel> -->	
  +  <goal name="jelly:showvars" prereqs="jelly-task"
  +    description="Displays the current variables in the Maven project">
  +    <java classname="org.apache.commons.jelly.Jelly" fork="yes">
  +      <classpath refid="test.classpath"/>
  +      <sysproperty key="http.proxyHost" value="${maven.proxy.host}"/>
  +      <sysproperty key="http.proxyPort" value="${maven.proxy.port}"/>
  +      <arg value="src/test/org/apache/commons/jelly/swing/showVariables.jelly"/>

  +    </java>
  +  </goal>
   </project>
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message