You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2003/01/06 17:40:36 UTC

cvs commit: jakarta-commons-sandbox/jelly/jelly-tags/swt project.xml project.properties .cvsignore maven.xml

dion        2003/01/06 08:40:36

  Added:       jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt
                        OnEventTag.java LayoutTagSupport.java
                        SwtHelper.java MenuTag.java LayoutTag.java
                        WidgetTag.java LayoutDataTag.java package.html
                        SwtTagLibrary.java
               jelly/jelly-tags/swt/src/test/org/apache/commons/jelly/tags/swt
                        tableTree.jelly example.jelly tree.jelly
               jelly/jelly-tags/swt project.xml project.properties
                        .cvsignore maven.xml
  Log:
  Move swt out into its own taglib
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/OnEventTag.java
  
  Index: OnEventTag.java
  ===================================================================
  /*
   * /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/swt/LayoutTagSupport.java,v 1.1 2002/12/18 15:27:49 jstrachan Exp
   * 1.1
   * 2002/12/18 15:27:49
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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/>.
   * 
   * LayoutTagSupport.java,v 1.1 2002/12/18 15:27:49 jstrachan Exp
   */
  package org.apache.commons.jelly.tags.swt;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.MissingAttributeException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.eclipse.swt.SWT;
  import org.eclipse.swt.widgets.Event;
  import org.eclipse.swt.widgets.Listener;
  import org.eclipse.swt.widgets.Widget;
  
  /** 
   * A tag which implements a Listener to allow events to be processed by
   * Jelly scripts
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version 1.1
   */
  public class OnEventTag extends TagSupport implements Listener {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(OnEventTag.class);
  
      private String var = "event";
      private String type; 
      private XMLOutput output;
  
      public OnEventTag() {
      }
  
      // Tag interface
      //-------------------------------------------------------------------------
      
      /**
       * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
       */
      public void doTag(XMLOutput output) throws Exception {
          if (var == null) {
              throw new MissingAttributeException("var");
          }
          if (type == null) {
              throw new MissingAttributeException("type");
          }
          
          Widget widget = getParentWidget();
          if (widget == null) {
              throw new JellyException("This tag must be nested within a widget tag");
          }
  
          
          int eventType = getEventType(type);
          if (eventType == 0) {
              throw new JellyException("No event type specified, could not understand: " + type);
          }
          
          this.output = output;
          widget.addListener(eventType, this);
      }
      
      // Listener interface
      //-------------------------------------------------------------------------
      /**
       * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
       */
      public void handleEvent(Event event) {
          try {
              context.setVariable(var, event);
              invokeBody(output);
          }
          catch (Exception e) {
              log.error("Caught exception: " + e + " while processing event: " + event, e);
          }
      }
      
      // Properties
      //-------------------------------------------------------------------------
  
      /**
       * @return the parent widget which this widget will be added to.
       */
      public Widget getParentWidget() {
          WidgetTag tag = (WidgetTag) findAncestorWithClass(WidgetTag.class);
          if (tag != null) {
              return tag.getWidget();
          }
          return null;
      }
  
      /**
       * Sets the name of the variable to use to expose the event object when
       * it is fired. If not specified this defaults to "event"
       */
      public void setVar(String var) {
          this.var = var;
      }
      
      /**
       * Returns the type.
       * @return String
       */
      public String getType() {
          return type;
      }
  
      /**
       * Sets the type of the event listener to listen for.
       * 
       * @param type The type of the event to listen for
       */
      public void setType(String type) {
          this.type = type;
      }
  
      // Implementation methods
      //-------------------------------------------------------------------------
  
      /**
       * Parses the given event type String and returns the SWT event type code
       *
       * @param type is the String event type
       * @return the SWT integer event type
       */
      protected int getEventType(String type) throws Exception {
          return SwtHelper.parseStyle(SWT.class, type, false);
      }
      
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/LayoutTagSupport.java
  
  Index: LayoutTagSupport.java
  ===================================================================
  /*
   * /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/swt/LayoutTagSupport.java,v 1.1 2002/12/18 15:27:49 jstrachan Exp
   * 1.1
   * 2002/12/18 15:27:49
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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/>.
   * 
   * LayoutTagSupport.java,v 1.1 2002/12/18 15:27:49 jstrachan Exp
   */
  package org.apache.commons.jelly.tags.swt;
  
  import java.lang.reflect.Field;
  import java.util.Iterator;
  import java.util.Map;
  
  import org.apache.commons.beanutils.BeanUtils;
  import org.apache.commons.beanutils.ConvertUtils;
  import org.apache.commons.jelly.tags.core.UseBeanTag;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.eclipse.swt.widgets.Widget;
  
  /** 
   * An abstract base class for Layout or LayoutData tags.
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version 1.1
   */
  public abstract class LayoutTagSupport extends UseBeanTag {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(LayoutTagSupport.class);
  
      private String var;
  
      public LayoutTagSupport(Class layoutClass) {
          super(layoutClass);
      }
  
      // Properties
      //-------------------------------------------------------------------------
  
      /**
       * @return the parent widget which this widget will be added to.
       */
      public Widget getParentWidget() {
          WidgetTag tag = (WidgetTag) findAncestorWithClass(WidgetTag.class);
          if (tag != null) {
              return tag.getWidget();
          }
          return null;
      }
  
      /**
       * Sets the name of the variable to use to expose the new Layout object. 
       * If this attribute is not set then the parent widget tag will have its 
       * layout property set.
       */
      public void setVar(String var) {
          this.var = var;
      }
      
      // Implementation methods
      //-------------------------------------------------------------------------                    
  
      /**
       * Either defines a variable or adds the current component to the parent
       */
      protected void processBean(String var, Object bean) throws Exception {
          if (var != null) {
              context.setVariable(var, bean);
          }
      }
      
      /**
       * @see org.apache.commons.jelly.tags.core.UseBeanTag#setBeanProperties(java.lang.Object, java.util.Map)
       */
      protected void setBeanProperties(Object bean, Map attributes)
          throws Exception {
              
          if (bean != null) {
              Class theClass = bean.getClass();
              for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext(); ) {
                  Map.Entry entry = (Map.Entry) iter.next();
                  String name = (String) entry.getKey();
                  Object value = entry.getValue();
                  
                  value = convertValue(bean, name, value);
                  
                  // lets first see if there's a field available
                  Field field = theClass.getField(name);
                  if (field != null) {
                      if (value instanceof String) {
                          value = ConvertUtils.convert((String) value, field.getType());
                      }
                      field.set(bean, value);
                  }
                  else {
                      BeanUtils.setProperty(bean, name, value);
                  }
              }
          }
      }
      
      /**
       * Provides a strategy method that allows values to be converted,
       * particularly to support integer enumerations and String representations.
       * 
       * @param bean is the bean on which the property is to be set
       * @param name is the name of the property 
       * @param value the value of the property
       * @return the new value
       */
      protected Object convertValue(Object bean, String name, Object value) throws Exception {
          return value;
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/SwtHelper.java
  
  Index: SwtHelper.java
  ===================================================================
  /*
   * /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/swt/SwtHelper.java,v 1.1 2002/12/18 15:27:49 jstrachan Exp
   * 1.1
   * 2002/12/18 15:27:49
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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/>.
   * 
   * SwtHelper.java,v 1.1 2002/12/18 15:27:49 jstrachan Exp
   */
  package org.apache.commons.jelly.tags.swt;
  
  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;
  
  /** 
   * A helper class for working with SWT.
   * </p>
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version 1.1
   */
  public class SwtHelper extends UseBeanTag {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(SwtHelper.class);
      
  
      /**
       * Parses the comma delimited String of style codes which are or'd
       * together. The given class describes the integer static constants
       *
       * @param constantClass is the type to look for static fields
       * @param text is a comma delimited text value such as "border, resize"
       * @return the int code
       */
      public static int parseStyle(Class constantClass, String text) throws Exception {
          return parseStyle(constantClass, text, true);
      }
  
      /**
       * Parses the comma delimited String of style codes which are or'd
       * together. The given class describes the integer static constants
       *
       * @param constantClass is the type to look for static fields
       * @param text is a comma delimited text value such as "border, resize"
       * @param toUpperCase is whether the text should be converted to upper case
       * before its compared against the reflection fields
       * 
       * @return the int code
       */
      public static int parseStyle(Class constantClass, String text, boolean toUpperCase) throws Exception {
          int answer = 0;
          if (text != null) {
              if (toUpperCase) {
                  text = text.toUpperCase();
              }
              StringTokenizer enum = new StringTokenizer(text, ",");
              while (enum.hasMoreTokens()) {
                  String token = enum.nextToken().trim();
                  answer |= getStyleCode(constantClass, token);
              }
          }
          return answer;
      }
      
      /**
       * @return the code for the given word or zero if the word doesn't match a
       * valid style
       */
      public static int getStyleCode(Class constantClass,String text) throws Exception {
          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);
          }
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/MenuTag.java
  
  Index: MenuTag.java
  ===================================================================
  /*
   * /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/swt/MenuTag.java,v 1.1 2002/12/18 15:27:49 jstrachan Exp
   * 1.1
   * 2002/12/18 15:27:49
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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/>.
   * 
   * MenuTag.java,v 1.1 2002/12/18 15:27:49 jstrachan Exp
   */
  package org.apache.commons.jelly.tags.swt;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.eclipse.swt.widgets.Control;
  import org.eclipse.swt.widgets.Decorations;
  import org.eclipse.swt.widgets.Menu;
  import org.eclipse.swt.widgets.MenuItem;
  import org.eclipse.swt.widgets.Widget;
  
  /** 
   * This tag creates an SWT Menu
   * </p>
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version 1.1
   */
  public class MenuTag extends WidgetTag {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(MenuTag.class);
      
      public MenuTag() {
          super(Menu.class);
      }
  
      /**
       * @return the parent Shell or returns null
       */
  /*    
      public Widget getParentWidget() {
          Widget parent = super.getParentWidget();
          if (parent instanceof Menu) {
              Menu menu = (Menu) parent;
              return menu.getShell();
          }
          return null;
      }
  */
      
      // Implementation methods
      //-------------------------------------------------------------------------                    
      
      /**
       * Provides a strategy method to allow a new child widget to be attached to
       * its parent
       * 
       * @param parent is the parent widget which is never null
       * @param widget is the new child widget to be attached to the parent
       */
      protected void attachWidgets(Widget parent, Widget widget) {
          Menu menu = (Menu) widget;
          if (parent instanceof Decorations) {
              Decorations shell = (Decorations) parent;
              shell.setMenuBar(menu);
          }
          else if (parent instanceof Control) {
              Control control = (Control) parent;
              control.setMenu(menu);
          }
          else if (parent instanceof MenuItem) {
              MenuItem menuItem = (MenuItem) parent;
              menuItem.setMenu(menu);
          }
      }
      
      /**
       * @see org.apache.commons.jelly.tags.swt.WidgetTag#createWidget(java.lang.Class, org.eclipse.swt.widgets.Widget, int)
       */
      protected Object createWidget(Class theClass, Widget parent, int style)
          throws Exception {
  
          if (parent instanceof Decorations) {            
              return super.createWidget(theClass, parent, style);
          }
          else {
              if (parent instanceof Menu) {
                  return new Menu((Menu) parent);
              }
              else if (parent instanceof MenuItem) {
                  return new Menu((MenuItem) parent);
              }
              else if (parent instanceof Control) {
                  return new Menu((Control) parent);
              }
              else {
                  throw new JellyException("This tag must be nested inside a <shell>, <menu>, <menuItem> or control tag");
              }
          }
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/LayoutTag.java
  
  Index: LayoutTag.java
  ===================================================================
  /*
   * /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/swt/LayoutTag.java,v 1.1 2002/12/18 15:27:49 jstrachan Exp
   * 1.1
   * 2002/12/18 15:27:49
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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/>.
   * 
   * LayoutTag.java,v 1.1 2002/12/18 15:27:49 jstrachan Exp
   */
  package org.apache.commons.jelly.tags.swt;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.eclipse.swt.SWT;
  import org.eclipse.swt.layout.FillLayout;
  import org.eclipse.swt.widgets.Composite;
  import org.eclipse.swt.widgets.Layout;
  import org.eclipse.swt.widgets.Widget;
  
  /** 
   * Creates a new Layout implementations and adds it to the parent Widget.
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version 1.1
   */
  public class LayoutTag extends LayoutTagSupport {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(LayoutTag.class);
  
      public LayoutTag(Class layoutClass) {
          super(layoutClass);
      }
  
      // Properties
      //-------------------------------------------------------------------------
  
      /**
       * @return the Layout if there is one otherwise null
       */
      public Layout getLayout() {
          Object bean = getBean();
          if ( bean instanceof Layout ) {
              return (Layout) bean;
          }
          return null;
      }
  
      // Implementation methods
      //-------------------------------------------------------------------------                    
  
      /**
       * Either defines a variable or adds the current component to the parent
       */
      protected void processBean(String var, Object bean) throws Exception {
          super.processBean(var, bean);
          
          Widget parent = getParentWidget();
          if (parent instanceof Composite) {
              Composite composite = (Composite) parent;
              composite.setLayout(getLayout());
          }
          else {
              throw new JellyException("This tag must be nested within a composite widget tag");
          }
      }
      
      /**
       * @see org.apache.commons.jelly.tags.swt.LayoutTagSupport#convertValue(java.lang.Object, java.lang.String, java.lang.Object)
       */
      protected Object convertValue(Object bean, String name, Object value)
          throws Exception {
              
          if (bean instanceof FillLayout && name.equals("type") && value instanceof String) {
              int style = SwtHelper.parseStyle(SWT.class, (String) value);
              return new Integer(style);
          }
          return super.convertValue(bean, name, value);
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/WidgetTag.java
  
  Index: WidgetTag.java
  ===================================================================
  /*
   * /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
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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/>.
   * 
   * WidgetTag.java,v 1.1 2002/12/18 15:27:49 jstrachan Exp
   */
  package org.apache.commons.jelly.tags.swt;
  
  import java.lang.reflect.Constructor;
  import java.util.Map;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.jelly.tags.core.UseBeanTag;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.eclipse.swt.SWT;
  import org.eclipse.swt.widgets.Widget;
  
  /** 
   * This tag creates an SWT widget based on the parent tag, optionally declaring
   * 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 1.1
   */
  public class WidgetTag extends UseBeanTag {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(WidgetTag.class);
      
      
      public WidgetTag(Class widgetClass) {
          super(widgetClass);
      }
  
      public String toString() {
          return "WidgetTag[widget=" + getWidget() + "]";
      }
  
  
      // Properties
      //-------------------------------------------------------------------------                    
  
      /**
       * @return the visible widget, if there is one.
       */
      public Widget getWidget() {
          Object bean = getBean();
          if ( bean instanceof Widget ) {
              return (Widget) bean;
          }
          return null;
      }
  
      /**
       * @return the parent widget which this widget will be added to.
       */
      public Widget getParentWidget() {
          WidgetTag tag = (WidgetTag) findAncestorWithClass(WidgetTag.class);
          if (tag != null) {
              return tag.getWidget();
          }
          return null;
      }
  
      
      // Implementation methods
      //-------------------------------------------------------------------------                    
  
      /**
       * Factory method to create a new widget
       */
      protected Object newInstance(Class theClass, Map attributes, XMLOutput output) throws Exception {
          int style = getStyle(attributes);
          
          // now lets call the constructor with the parent
          Widget parent = getParentWidget();
          Widget widget = (Widget) createWidget(theClass, parent, style);
          if (parent != null) {
              attachWidgets(parent, widget);
          }
          return widget; 
      }
      
      /**
       * Provides a strategy method to allow a new child widget to be attached to
       * its parent
       * 
       * @param parent is the parent widget which is never null
       * @param widget is the new child widget to be attached to the parent
       */
      protected void attachWidgets(Widget parent, Widget widget) {
      }
      
      /**
       * Factory method to create an instance of the given Widget class with
       * the given parent and SWT style
       * 
       * @param theClass is the type of widget to create
       * @param parent is the parent widget
       * @param style the SWT style code
       * @return the new Widget
       */
      protected Object createWidget(Class theClass, Widget parent, int style) throws Exception {
          if (theClass == null) {
              throw new JellyException( "No Class available to create the new widget");
          }
          if (parent == null) {
              // lets try call a constructor with a single style
              Class[] types = { int.class };
              Constructor constructor = theClass.getConstructor(types);
              if (constructor != null) {
                  Object[] arguments = { new Integer(style)};
                  return constructor.newInstance(arguments);
              }
          }
          else {
              // lets try to find the constructor with 2 arguments with the 2nd argument being an int
              Constructor[] constructors = theClass.getConstructors();
              if (constructors != null) {
                  for (int i = 0, size = constructors.length; i < size; i++ ) {
                      Constructor constructor = constructors[i];
                      Class[] types = constructor.getParameterTypes();
                      if (types.length == 2 && types[1].isAssignableFrom(int.class)) {
                          if (types[0].isAssignableFrom(parent.getClass())) {
                              Object[] arguments = { parent, new Integer(style)};
                              return constructor.newInstance(arguments);
                          }
                      }
                  }
              }
          }
          return theClass.newInstance();
      }
      
      /**
       * Creates the SWT style code for the current attributes
       * @return the SWT style code
       */
      protected int getStyle(Map attributes) throws Exception {
          String text = (String) attributes.remove("style");
          if (text != null) {
              return SwtHelper.parseStyle(SWT.class, text);
          }
          return SWT.DEFAULT;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/LayoutDataTag.java
  
  Index: LayoutDataTag.java
  ===================================================================
  /*
   * /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/swt/LayoutDataTag.java,v 1.1 2002/12/18 15:27:49 jstrachan Exp
   * 1.1
   * 2002/12/18 15:27:49
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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/>.
   * 
   * LayoutDataTag.java,v 1.1 2002/12/18 15:27:49 jstrachan Exp
   */
  package org.apache.commons.jelly.tags.swt;
  
  import java.lang.reflect.Constructor;
  import java.util.Map;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.eclipse.swt.layout.GridData;
  import org.eclipse.swt.widgets.Control;
  import org.eclipse.swt.widgets.Widget;
  
  /** 
   * Creates a LayoutData object and sets it on the parent Widget.
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version 1.1
   */
  public class LayoutDataTag extends LayoutTagSupport {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(LayoutDataTag.class);
  
      public LayoutDataTag(Class layoutDataClass) {
          super(layoutDataClass);
      }
  
      // Implementation methods
      //-------------------------------------------------------------------------                    
  
      /**
       * Either defines a variable or adds the current component to the parent
       */
      protected void processBean(String var, Object bean) throws Exception {
          super.processBean(var, bean);
  
          Widget parent = getParentWidget();
          
          if (parent instanceof Control) {
              Control control = (Control) parent;
              control.setLayoutData(getBean());
          }
          else {
              throw new JellyException("This tag must be nested within a control widget tag");
          }
      }
      
      
      /**
       * @see org.apache.commons.jelly.tags.core.UseBeanTag#newInstance(java.lang.Class, java.util.Map, org.apache.commons.jelly.XMLOutput)
       */
      protected Object newInstance(
          Class theClass,
          Map attributes,
          XMLOutput output)
          throws Exception {
              
          String text = (String) attributes.remove("style");
          if (text != null) {
              int style = SwtHelper.parseStyle(theClass, text);
              
              // now lets try invoke a constructor
              Class[] types = { int.class };
              Constructor constructor = theClass.getConstructor(types);
              if (constructor != null) {
                  Object[] values = { new Integer(style) };
                  return constructor.newInstance(values);
              }
          }
          return super.newInstance(theClass, attributes, output);
      }
  
      /**
       * @see org.apache.commons.jelly.tags.swt.LayoutTagSupport#convertValue(java.lang.Object, java.lang.String, java.lang.Object)
       */
      protected Object convertValue(Object bean, String name, Object value)
          throws Exception {
  
          if (bean instanceof GridData) {
              if (name.endsWith("Alignment") && value instanceof String) {
                  int style = SwtHelper.parseStyle(bean.getClass(), (String) value);
                  return new Integer(style);
              }
          }
          return super.convertValue(bean, name, value);
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  </head>
  <body>
  
    <p>
    	The JellySWT Library is a Jelly Library for creating Rich User Interfaces 
    	using SWT via XML markup (a Jelly script)
    </p>
    
  </body>
  </html>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/SwtTagLibrary.java
  
  Index: SwtTagLibrary.java
  ===================================================================
  /*
   * /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/swt/SwtTagLibrary.java,v 1.1 2002/12/18 15:27:49 jstrachan Exp
   * 1.1
   * 2002/12/18 15:27:49
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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/>.
   * 
   * SwtTagLibrary.java,v 1.1 2002/12/18 15:27:49 jstrachan Exp
   */
  package org.apache.commons.jelly.tags.swt;
  
  import org.eclipse.swt.layout.FillLayout;
  import org.eclipse.swt.layout.GridData;
  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;
  import org.apache.commons.jelly.TagLibrary;
  import org.apache.commons.jelly.impl.TagFactory;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  import org.xml.sax.Attributes;
  
  /** 
   * A Jelly custom tag library that creates SWT user interfaces
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version 1.1
   */
  public class SwtTagLibrary extends TagLibrary {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(SwtTagLibrary.class);
  
      static {
          // we could create Converters from Strings to various SWT types 
      }
          
      public SwtTagLibrary() {
          // widgets
          registerWidgetTag( "button", Button.class );
          registerWidgetTag( "canvas", Canvas.class );
          registerWidgetTag( "caret", Caret.class );
          registerWidgetTag( "combo", Combo.class );
          registerWidgetTag( "composite", Composite.class );
          registerWidgetTag( "coolBar", CoolBar.class );
          registerWidgetTag( "coolItem", CoolItem.class );
          registerWidgetTag( "decorations", Decorations.class );
          registerWidgetTag( "group", Group.class );
          registerWidgetTag( "label", Label.class );
          registerWidgetTag( "list", List.class );
          registerTag( "menu", MenuTag.class );
          registerWidgetTag( "menuItem", MenuItem.class );
          registerWidgetTag( "messageBox", MessageBox.class );
          registerWidgetTag( "progressBar", ProgressBar.class );
          registerWidgetTag( "sash", Sash.class );
          registerWidgetTag( "scale", Scale.class );
          registerWidgetTag( "shell", Shell.class );
          registerWidgetTag( "slider", Slider.class );
          registerWidgetTag( "tabFolder", TabFolder.class );
          registerWidgetTag( "tabItem", TabItem.class );
          registerWidgetTag( "table", Table.class );
          registerWidgetTag( "tableColumn", TableColumn.class );
          registerWidgetTag( "tableItem", TableItem.class );
          registerWidgetTag( "text", Text.class );
          registerWidgetTag( "toolBar", ToolBar.class );
          registerWidgetTag( "toolItem", ToolItem.class );
          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);
          registerLayoutTag("gridLayout", GridLayout.class);
          registerLayoutTag("rowLayout", RowLayout.class);
  
          // layout data objects
          registerLayoutDataTag( "gridData", GridData.class );
          registerLayoutDataTag( "rowData", RowData.class );
  
          // dialogs        
          //registerWidgetTag( "colorDialog", ColorDialog.class );
          //registerWidgetTag( "directoryDialog", DirectoryDialog.class );
          //registerWidgetTag( "fileDialog", FileDialog.class );
          //registerWidgetTag( "fontDialog", FontDialog.class );
          
          // events
          registerTag("onEvent", OnEventTag.class);
      }
  
      /**
       * Register a layout tag for the given name
       */
      protected void registerLayoutTag(String name, final Class layoutClass) {
          registerTagFactory(
              name,
              new TagFactory() {
                  /**
                   * @see org.apache.commons.jelly.impl.TagFactory#createTag(java.lang.String, org.xml.sax.Attributes)
                   */
                  public Tag createTag(String name, Attributes attributes)
                      throws Exception {
                      return new LayoutTag(layoutClass);
                  }
              }
          );
      }
  
      /**
       * Register a layout data tag for the given name
       */
      protected void registerLayoutDataTag(String name, final Class layoutDataClass) {
          registerTagFactory(
              name,
              new TagFactory() {
                  /**
                   * @see org.apache.commons.jelly.impl.TagFactory#createTag(java.lang.String, org.xml.sax.Attributes)
                   */
                  public Tag createTag(String name, Attributes attributes)
                      throws Exception {
                      return new LayoutDataTag(layoutDataClass);
                  }
              }
          );
      }
  
      /**
       * Register a widget tag for the given name
       */
      protected void registerWidgetTag(String name, final Class widgetClass) {
          registerTagFactory(
              name,
              new TagFactory() {
                  /**
                   * @see org.apache.commons.jelly.impl.TagFactory#createTag(java.lang.String, org.xml.sax.Attributes)
                   */
                  public Tag createTag(String name, Attributes attributes)
                      throws Exception {
                      return new WidgetTag(widgetClass);
                  }
              }
          );
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/swt/src/test/org/apache/commons/jelly/tags/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>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/swt/src/test/org/apache/commons/jelly/tags/swt/example.jelly
  
  Index: example.jelly
  ===================================================================
  <?xml version="1.0"?>
  <j:jelly xmlns:j="jelly:core" xmlns="jelly:swt" xmlns:log="jelly:log">
  
    <shell text="This is a shell" var="shell" style="border, close, min, max, resize, title">
  		<menu style="bar">
  			<menuItem text="File" style="cascade">
  				<menu>
  					<menuItem text="New">
  						<onEvent type="Selection">
  							<log:info>Selected New option with event ${event}</log:info>
  						</onEvent>
  					</menuItem>
  						
  					<menuItem text="Open"/>
  					<menuItem style="separator"/>
  					<menuItem text="Save"/>
  				</menu>
  			</menuItem>
  			<menuItem text="Help" style="cascade">
  				<menu>
  					<menuItem text="About"/>
  				</menu>
  			</menuItem>
  		</menu>  	
  
    	<gridLayout/>
  
  		<group text="Some form">
  			<gridData style="fill_horizontal"/>
  
  			<gridLayout numColumns="2"/>
  			<label text="Hello" style="horizontal, shadow_in"/>
  			<text var="textField" text="1234" editable="true">
  				<gridData style="fill_horizontal"/>
  			</text>
  		</group>
  
  		<table 
  			headerVisible="true"
  			linesVisible="true"
  			toolTipText="This is a table!" 
  			style="multi, border, full_selection">
  			
  			<gridData style="fill_both"/>
  			
  			<tableColumn text="Name" width="100" toolTipText="This is the name column"/>
  			<tableColumn text="Age" width="40" toolTipText="This is the age column"/>
  			
  			<!-- we'd normally use some Java bean model to implement the next bit -->
  			<tableItem var="row"/>
  			${row.setText(0, 'James')}
  			${row.setText(1, '33')}
  			<tableItem var="row"/>
  			${row.setText(0, 'Bob')}
  			${row.setText(1, '30')}
  		</table>
  
    	<toolBar style="vertical">
    		<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>
    </shell>
  
  	<!-- we could abstract the following away as a tag -->
  	
  	${shell.pack()}
  	${shell.open()}
  	
  	<j:set var="display" value="${shell.display}"/>
  	
  	<j:while test="${!shell.isDisposed()}">
  		<j:if test="${!display.readAndDispatch()}">
  			<j:set var="foo" value="${display.sleep()}"/>
  		</j:if>
  	</j:while>
  	${display.dispose()}
  </j:jelly>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/swt/src/test/org/apache/commons/jelly/tags/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/jelly-tags/swt/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE project [
    <!-- see file for description -->
    <!ENTITY commonDeps SYSTEM "file:../../commonDependencies.ent">
  ]>
  <project>
    <extend>../tag-project.xml</extend>
    <id>commons-jelly-tags-swt</id>
    <name>commons-jelly-tags-swt</name>
    <groupId>commons-jelly</groupId>
    <package>org.apache.commons.jelly.tags.swt</package>
  
    <description>
        This is a Jelly interface for SWT.
    </description>
    <shortDescription>Commons Jelly SWT Tag Library</shortDescription>
    
    <siteDirectory>/www/jakarta.apache.org/commons/sandbox/jelly/tags/swt</siteDirectory>
    <distributionDirectory>/www/jakarta.apache.org/builds/jakarta-commons-sandbox/jelly/tags/swt</distributionDirectory>
    <repository>
      <connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:jakarta-commons-sandbox/jelly/jelly-tags/swt/</connection>
      <url>http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/jelly/jelly-tags/swt/</url>
    </repository>
    
      
    <dependencies>
    
      &commonDeps;
    
      <!-- START for compilation -->
    
      <dependency>
        <id>commons-jelly</id>
        <version>SNAPSHOT</version>
      </dependency>
    
  	<!-- swt taglib -->
      <dependency>
        <id>swt</id>
        
        <!-- don't know how to support OS-dependent jars in Maven yet -->
        <version>win32-2.1.0</version>
      </dependency>
      
      <!-- END for compilation -->
      
    </dependencies>
    
  </project>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/swt/project.properties
  
  Index: project.properties
  ===================================================================
  # -------------------------------------------------------------------
  # P R O J E C T  P R O P E R T I E S
  # -------------------------------------------------------------------
  
  maven.junit.fork=true
  
  maven.compile.deprecation = on
  
  # Installation dir
  maven.dist.install.dir = /usr/local/jelly
  
  maven.checkstyle.properties=../tag-checkstyle.properties
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/swt/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  maven.log
  target
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/swt/maven.xml
  
  Index: maven.xml
  ===================================================================
  <project default="java:jar">
  
  </project>
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>