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/src/test/org/apache/commons/jelly/swt tree.jelly tableTree.jelly example.jelly
Date Thu, 19 Dec 2002 17:22:37 GMT
jstrachan    2002/12/19 09:22:36

  Modified:    jelly/src/java/org/apache/commons/jelly/tags/swt
                        SwtHelper.java WidgetTag.java SwtTagLibrary.java
               jelly/src/test/org/apache/commons/jelly/swt example.jelly
  Added:       jelly/src/test/org/apache/commons/jelly/swt tree.jelly
                        tableTree.jelly
  Log:
  Patch to add better error reporting if wrong SWT style codes are used and handle constructors
of widgets better.
  
  Also added an example of using trees. Have added a TableTree example but can't seem to get
the text values to dislpay :-(
  
  Revision  Changes    Path
  1.3       +11 -5     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/swt/SwtHelper.java
  
  Index: SwtHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/swt/SwtHelper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SwtHelper.java	18 Dec 2002 18:42:29 -0000	1.2
  +++ SwtHelper.java	19 Dec 2002 17:22:36 -0000	1.3
  @@ -64,6 +64,7 @@
   import java.lang.reflect.Field;
   import java.util.StringTokenizer;
   
  +import org.apache.commons.jelly.JellyException;
   import org.apache.commons.jelly.tags.core.UseBeanTag;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  @@ -124,11 +125,16 @@
        * valid style
        */
       public static int getStyleCode(Class constantClass,String text) throws Exception {
  -        Field field = constantClass.getField(text);
  -        if (field == null) {
  -            log.warn( "Unknown style code: " + text +" will be ignored");
  -            return 0;
  +        try {
  +            Field field = constantClass.getField(text);
  +            if (field == null) {
  +                log.warn( "Unknown style code: " + text +" will be ignored");
  +                return 0;
  +            }
  +            return field.getInt(null);
  +        }
  +        catch (Exception e) {
  +            throw new JellyException("The value: " + text + " is not understood", e);
           }
  -        return field.getInt(null);
       }
   }
  
  
  
  1.2       +9 -7      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/swt/WidgetTag.java
  
  Index: WidgetTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/swt/WidgetTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WidgetTag.java	18 Dec 2002 15:27:49 -0000	1.1
  +++ WidgetTag.java	19 Dec 2002 17:22:36 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header$
  - * $Revision$
  - * $Date$
  + * /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/swt/WidgetTag.java,v
1.1 2002/12/18 15:27:49 jstrachan Exp
  + * 1.1
  + * 2002/12/18 15:27:49
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id$
  + * WidgetTag.java,v 1.1 2002/12/18 15:27:49 jstrachan Exp
    */
   package org.apache.commons.jelly.tags.swt;
   
  @@ -77,7 +77,7 @@
    * this widget as a variable if the <i>var</i> attribute is specified.</p>
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  - * @version $Revision$
  + * @version 1.1
    */
   public class WidgetTag extends UseBeanTag {
   
  @@ -178,8 +178,10 @@
                       Constructor constructor = constructors[i];
                       Class[] types = constructor.getParameterTypes();
                       if (types.length == 2 && types[1].isAssignableFrom(int.class))
{
  -                        Object[] arguments = { parent, new Integer(style)};
  -                        return constructor.newInstance(arguments);
  +                        if (types[0].isAssignableFrom(parent.getClass())) {
  +                            Object[] arguments = { parent, new Integer(style)};
  +                            return constructor.newInstance(arguments);
  +                        }
                       }
                   }
               }
  
  
  
  1.3       +5 -0      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/swt/SwtTagLibrary.java
  
  Index: SwtTagLibrary.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/swt/SwtTagLibrary.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SwtTagLibrary.java	18 Dec 2002 18:42:29 -0000	1.2
  +++ SwtTagLibrary.java	19 Dec 2002 17:22:36 -0000	1.3
  @@ -66,6 +66,7 @@
   import org.eclipse.swt.layout.GridLayout;
   import org.eclipse.swt.layout.RowData;
   import org.eclipse.swt.layout.RowLayout;
  +import org.eclipse.swt.custom.*;
   import org.eclipse.swt.widgets.*;
   
   import org.apache.commons.jelly.Tag;
  @@ -124,6 +125,10 @@
           registerWidgetTag( "tracker", Tracker.class );
           registerWidgetTag( "tree", Tree.class );
           registerWidgetTag( "treeItem", TreeItem.class );
  +
  +        // custom widgets
  +        registerWidgetTag( "tableTree", TableTree.class );
  +        registerWidgetTag( "tableTreeItem", TableTreeItem.class );
   
           // layouts        
           registerLayoutTag("fillLayout", FillLayout.class);
  
  
  
  1.4       +11 -1     jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/swt/example.jelly
  
  Index: example.jelly
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/swt/example.jelly,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- example.jelly	18 Dec 2002 18:42:16 -0000	1.3
  +++ example.jelly	19 Dec 2002 17:22:36 -0000	1.4
  @@ -56,9 +56,19 @@
   		</table>
   
     	<toolBar style="vertical">
  -  		<toolItem text="ToolBar Item" toolTipText="I am a ToolBar Item that you can click">
  +  		<toolItem text="Click Me" toolTipText="I am a ToolBar Item that you can click">
     			<onEvent type="Selection">
     				<log:info>Clicked button with event ${event} and text field contains ${textField.text}</log:info>
  +  			</onEvent>
  +			</toolItem>
  +  		<toolItem text="Tree" toolTipText="Starts the Tree demo">
  +  			<onEvent type="Selection">
  +  				<j:include uri="tree.jelly"/>
  +  			</onEvent>
  +			</toolItem>
  +  		<toolItem text="TableTree" toolTipText="Starts the TableTree demo">
  +  			<onEvent type="Selection">
  +  				<j:include uri="tableTree.jelly"/>
     			</onEvent>
   			</toolItem>
     	</toolBar>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/swt/tree.jelly
  
  Index: tree.jelly
  ===================================================================
  <?xml version="1.0"?>
  <j:jelly xmlns:j="jelly:core" xmlns="jelly:swt" xmlns:log="jelly:log">
  
    <shell text="Tree Demo" var="shell" style="border, close, min, max, resize, title">
    	
    	<gridLayout/>
  
  		<tree toolTipText="This is a tree!" style="multi">
  			
  			<gridData style="fill_both"/>
  			
  			<!-- we'd normally use some Java bean model to implement the next bit -->
  			<treeItem text="A">
  				<treeItem text="A/A"/>
  				<treeItem text="A/B"/>
  				<treeItem text="A/C"/>
  			</treeItem>
  			<treeItem text="B">
  				<treeItem text="B/A"/>
  				<treeItem text="B/B"/>
  				<treeItem text="B/C"/>
  			</treeItem>
  							
  			<menu style="pop_up">
  				<menuItem text="do something!">
  					<onEvent type="Selection">
  						<log:info>Clicked on ${event}</log:info>
  					</onEvent>
  				</menuItem>
  			</menu>							
  		</tree>
    </shell>
  
  	${shell.pack()}
  	${shell.open()}
  </j:jelly>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/swt/tableTree.jelly
  
  Index: tableTree.jelly
  ===================================================================
  <?xml version="1.0"?>
  <j:jelly xmlns:j="jelly:core" xmlns="jelly:swt" xmlns:log="jelly:log">
  
    <shell text="TableTree Demo" var="shell" style="border, close, min, max, resize, title">
    	
    	<gridLayout/>
  
  		<tableTree toolTipText="This is a table tree!" style="multi, full_selection">
  			
  			<gridData style="fill_both"/>
  			
  			<!-- we'd normally use some Java bean model to implement the next bit -->
  			<tableTreeItem var="row">
  					${row.setText('A')}
  					${row.setText(0, 'James')}
  					${row.setText(1, '33')}
  				<tableTreeItem>
  					${row.setText('B')}
  					${row.setText(0, 'Child')}
  					${row.setText(1, '2')}
  				</tableTreeItem>
  				
  				<tableTreeItem>
  					${row.setText(0, 'Child-nosettext')}
  					${row.setText(1, '2')}
  				</tableTreeItem>
  				
  				<tableTreeItem var="row">
  					${row.setText('C')}
  					${row.setText(0, 'Bob')}
  					${row.setText(1, '30')}
  
  					<tableTreeItem var="row">
  						${row.setText('C')}
  					</tableTreeItem>
  
  				</tableTreeItem>
  			</tableTreeItem>
  							
  		</tableTree>
    </shell>
  
  	${shell.open()}
  </j:jelly>
  
  
  

--
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