You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by js...@apache.org on 2002/12/18 16:27:50 UTC

cvs commit: jakarta-commons-sandbox/jelly project.xml maven.xml

jstrachan    2002/12/18 07:27:50

  Modified:    jelly/xdocs navigation.xml
               jelly/src/java/org/apache/commons/jelly jelly.properties
               jelly    project.xml maven.xml
  Added:       jelly/src/java/org/apache/commons/jelly/tags/swt
                        LayoutDataTag.java SwtTagLibrary.java MenuTag.java
                        SwtHelper.java LayoutTagSupport.java LayoutTag.java
                        WidgetTag.java package.html
               jelly/xdocs jellyswt.xml
               jelly/src/test/org/apache/commons/jelly/swt example.jelly
  Log:
  Added an initial implementation of JellySWT which is an XML language for creating rich user interfaces using SWT.
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/jelly/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/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.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 );
  
          // 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 );
      }
  
      /**
       * 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/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/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.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 text is a comma delimited text value such as "border, resize" 
       * @return int
       */
      public static int parseStyle(Class constantClass, String text) throws Exception {
          int answer = 0;
          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 {
          text = text.toUpperCase();
          Field field = constantClass.getField(text);
          if (field == null) {
              log.warn( "Unknown style code: " + text +" will be ignored");
              return 0;
          }
          return field.getInt(null);
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/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/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/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)) {
                          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/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.18      +1 -0      jakarta-commons-sandbox/jelly/xdocs/navigation.xml
  
  Index: navigation.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/xdocs/navigation.xml,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- navigation.xml	11 Dec 2002 20:02:46 -0000	1.17
  +++ navigation.xml	18 Dec 2002 15:27:50 -0000	1.18
  @@ -22,6 +22,7 @@
       <menu name="Features">
         <item name="JellyUnit"               href="/jellyunit.html"/>
         <item name="JellySwing"              href="/jellyswing.html"/>
  +      <item name="JellySWT"                href="/jellyswt.html"/>
         <item name="XML Pipeline"            href="/pipeline.html"/>
         <item name="Tag Reference"           href="/tags.html"/>
       </menu>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/xdocs/jellyswt.xml
  
  Index: jellyswt.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <document>
    <properties>
      <title>JellySWT</title>
      <author email="jstrachan@apache.org">James Strachan</author>
    </properties>
  
    <body>
      <section name="JellySWT"> 
        <p>
          JellySWT is a simple Jelly library which can be used to create SWT user interfaces.
          It allows XML documents (Jelly scripts) to be used to define the layout and rendering of SWT
          front ends which avoids lots of mundane Java coding, using markup to define the view 
          of your front end and allowing you to bind to Java code for the business objects and models. 
        </p>
        <p>
          This mechanism uses seperation of concerns and MVC ideas from web applications, allowing the rendering
          of your SWT front end to be easily transformed (since its XML) into different styles while leaving your
          model and business objects untouched. It also allows different views to be constructed independently of your models.
        </p>
        <p>
          There is an example JellySWT script
          <a href="http://cvs.apache.org/viewcvs.cgi/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/swt/example.jelly?rev=HEAD">here</a>
        </p>
        <p>
          To try running the example type the following command then you should see a full SWT user interface 
          appear with pull down menus, a simple form, a table, toolbar buttons, tooltip etc.
        </p>
        <source>
  	maven demo:swt
        </source>
      </section>
      
      <section name="Running SWT"> 
        <p>
          Please be aware that SWT uses JNI and so requires a runtime library to be on your PATH for any SWT application to run.
          You can refer to this <a href="http://eclipsewiki.swiki.net/26">FAQ</a> entry for more details.
        </p>
        <p>
          For example on my windows laptop I copied the <i>swt-win32-2116.dll</i> from Eclipse into my PATH before running the examples.
        </p>
      </section>
      
      <section name="Useful SWT Links"> 
      	<ul>
        <li>
          <a href="http://www.eclipse.org/documentation/html/plugins/org.eclipse.platform.doc.isv/doc/reference/api/index.html">SWT Javadoc</a> 
          is very handy. Its mostly the widgets package thats of most interest.
        </li>
        <li>
          This <a href="http://eclipsewiki.swiki.net/2">SWT Wiki</a> has lots of good examples and documentation.
        </li>
        <li>
        	This <a href="http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html">page</a> also has a list of lots of little example SWT applications.
        </li>
      	</ul>
      </section>
      
    </body>
  </document>
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/swt/example.jelly
  
  Index: example.jelly
  ===================================================================
  <?xml version="1.0"?>
  <j:jelly xmlns:j="jelly:core" xmlns="jelly:swt">
  
    <shell text="This is a shell" var="shell" style="border, close, min, max, resize, title">
  		<menu style="bar">
  			<menuItem text="File" style="cascade">
  				<menu style="drop_down">
  					<menuItem text="New"/>
  					<menuItem text="Open"/>
  					<menuItem style="separator"/>
  					<menuItem text="Save"/>
  				</menu>
  			</menuItem>
  			<menuItem text="Help" style="cascade">
  				<menu style="drop_down">
  					<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 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="ToolBar Item" toolTipText="I am a ToolBar Item that you can click"/>
    	</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.30      +1 -0      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/jelly.properties
  
  Index: jelly.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/jelly.properties,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- jelly.properties	27 Nov 2002 16:46:09 -0000	1.29
  +++ jelly.properties	18 Dec 2002 15:27:50 -0000	1.30
  @@ -16,6 +16,7 @@
   
   # optional taglibs
   swing	    = org.apache.commons.jelly.tags.swing.SwingTagLibrary
  +swt		    = org.apache.commons.jelly.tags.swt.SwtTagLibrary
   soap		= org.apache.commons.jelly.tags.soap.SoapTagLibrary
   xmlunit		= org.apache.commons.jelly.tags.xmlunit.XMLUnitTagLibrary
   html		= org.apache.commons.jelly.tags.html.HTMLTagLibrary
  
  
  
  1.102     +8 -0      jakarta-commons-sandbox/jelly/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/project.xml,v
  retrieving revision 1.101
  retrieving revision 1.102
  diff -u -r1.101 -r1.102
  --- project.xml	16 Dec 2002 10:51:06 -0000	1.101
  +++ project.xml	18 Dec 2002 15:27:50 -0000	1.102
  @@ -495,6 +495,14 @@
         <id>xmlunit</id>
         <version>0.8</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>
     </dependencies>
     <build>
       <nagEmailAddress>commons-dev@jakarta.apache.org</nagEmailAddress>
  
  
  
  1.49      +8 -0      jakarta-commons-sandbox/jelly/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/maven.xml,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- maven.xml	11 Dec 2002 20:01:37 -0000	1.48
  +++ maven.xml	18 Dec 2002 15:27:50 -0000	1.49
  @@ -567,4 +567,12 @@
       </copy>
     </postGoal>
     
  +  <goal name="demo:swt" prereqs="jelly-task" 
  +		description="Runs a JellySWT demo">
  +    <java classname="org.apache.commons.jelly.Jelly" fork="yes">
  +      <classpath refid="test.classpath"/>
  +      <arg value="src/test/org/apache/commons/jelly/swt/example.jelly"/> 
  +    </java>
  +  </goal>
  +
   </project>
  
  
  

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