jstrachan    2003/02/26 04:53:37

  Modified:    jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt
                        LayoutDataTag.java ImageTag.java LayoutTag.java
                        LayoutTagSupport.java WidgetTag.java
               
jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/wizard
                        WizardDialogTag.java
               jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface
                        JFaceTagLibrary.java ViewerTag.java
                        MenuManagerTag.java
               
jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/preference
                        PreferenceDialogTag.java
               jelly/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/jface
                        JFaceDemo.jelly
               jelly/jelly-tags/jface maven.xml
  Added:       jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface
                        JFaceWidgetTag.java JFaceImageTag.java
                        JFaceLayoutTag.java JFaceLayoutDataTag.java
               
jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/window
                        ApplicationWindowTag.java
                        ApplicationWindowImpl.java
               jelly/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/jface
                        JFaceDemo.java
  Removed:     jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface
                        ApplicationWindowTag.java
  Log:
  Applied latest patches supplied by Christiaan ten Klooster for a JFace demo, 
properties editing and Wizard support. 
  Neat!
  
  Revision  Changes    Path
  1.5       +11 -11    
jakarta-commons/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/LayoutDataTag.java
  
  Index: LayoutDataTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/LayoutDataTag.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LayoutDataTag.java        24 Jan 2003 22:53:33 -0000      1.4
  +++ LayoutDataTag.java        26 Feb 2003 12:53:36 -0000      1.5
  @@ -94,21 +94,20 @@
       /**
        * Either defines a variable or adds the current component to the parent
        */
  -    protected void processBean(String var, Object bean) throws JellyTagException {
  +    protected void processBean(String var, Object bean)
  +        throws JellyTagException {
           super.processBean(var, bean);
   
           Widget parent = getParentWidget();
  -        
  +
           if (parent instanceof Control) {
               Control control = (Control) parent;
               control.setLayoutData(getBean());
  -        }
  -        else {
  +        } else {
               throw new JellyTagException("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)
        */
  @@ -117,18 +116,18 @@
           Map attributes,
           XMLOutput output)
           throws JellyTagException {
  -            
  +
           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 };
  -            
  +
               try {
                   Constructor constructor = theClass.getConstructor(types);
                   if (constructor != null) {
  -                    Object[] values = { new Integer(style) };
  +                    Object[] values = { new Integer(style)};
                       return constructor.newInstance(values);
                   }
               } catch (NoSuchMethodException e) {
  @@ -152,7 +151,8 @@
   
           if (bean instanceof GridData) {
               if (name.endsWith("Alignment") && value instanceof String) {
  -                int style = SwtHelper.parseStyle(bean.getClass(), (String) value);
  +                int style =
  +                    SwtHelper.parseStyle(bean.getClass(), (String) value);
                   return new Integer(style);
               }
           }
  
  
  
  1.3       +64 -55    
jakarta-commons/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/ImageTag.java
  
  Index: ImageTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/ImageTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ImageTag.java     20 Feb 2003 18:07:18 -0000      1.2
  +++ ImageTag.java     26 Feb 2003 12:53:36 -0000      1.3
  @@ -74,38 +74,38 @@
    */
   public class ImageTag extends TagSupport {
   
  -     /** path to file */
  -     private String src;
  +    /** path to file */
  +    private String src;
   
  -     public ImageTag() {
  -     }
  +    public ImageTag() {
  +    }
   
  -     /**
  -      * Sets the src.
  -      * @param src The src to set
  -      */
  -     public void setSrc(String src) {
  -             this.src = src;
  -     }
  -
  -     /**
  -      * Method getSrc.
  -      * @return String
  -      */
  -     public String getSrc() {
  -             return src;
  -     }
  -
  -     /**
  -      * @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 src.
  +     * @param src The src to set
  +     */
  +    public void setSrc(String src) {
  +        this.src = src;
  +    }
  +
  +    /**
  +     * Method getSrc.
  +     * @return String
  +     */
  +    public String getSrc() {
  +        return src;
  +    }
  +
  +    /**
  +     * @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;
  +    }
   
       // Tag interface
       //-------------------------------------------------------------------------
  @@ -116,33 +116,42 @@
       public void doTag(XMLOutput output) throws JellyTagException {
           // invoke by body just in case some nested tag configures me
           invokeBody(output);
  -        
  -             Widget parent = getParentWidget();
  +
  +        Widget parent = getParentWidget();
  +
           if (parent == null) {
  -            throw new JellyTagException("This tag must be nested within a widget");
  +            throw new JellyTagException("This tag must be nested within a Widget or 
a Window");
           }
  -        
  -             Image image = new Image(parent.getDisplay(), getSrc());
   
  -             if (parent instanceof Label) {
  -                     Label label = (Label) parent;
  -                     label.setImage(image);
  -
  -             } else if (parent instanceof Button) {
  -                     Button button = (Button) parent;
  -                     button.setImage(image);
  -                     
  -             } else if (parent instanceof Item) {
  -                     Item item = (Item) parent;
  -                     item.setImage(image);
  -                     
  -             } else if (parent instanceof Decorations) {
  -                     Decorations item = (Decorations) parent;
  -                     item.setImage(image);
  -                     
  -             } else {
  -                     throw new JellyTagException("This tag must be nested inside a 
<label>, <button> or <item> tag");
  -             }
  -     }
  +        Image image = new Image(parent.getDisplay(), getSrc());
  +        setWidgetImage(parent, image);
  +    }
   
  +    /**
  +     * Add image to a widget
  +     * @param parent
  +     * @param image
  +     * @throws JellyTagException
  +     */
  +    protected void setWidgetImage(Widget parent, Image image) throws 
JellyTagException {
  +        if (parent instanceof Label) {
  +            Label label = (Label) parent;
  +            label.setImage(image);
  +
  +        } else if (parent instanceof Button) {
  +            Button button = (Button) parent;
  +            button.setImage(image);
  +
  +        } else if (parent instanceof Item) {
  +            Item item = (Item) parent;
  +            item.setImage(image);
  +
  +        } else if (parent instanceof Decorations) {
  +            Decorations item = (Decorations) parent;
  +            item.setImage(image);
  +
  +        } else {
  +            throw new JellyTagException("This tag must be nested inside a <label>, 
<button> or <item> tag");
  +        }
  +    }
   }
  
  
  
  1.4       +12 -8     
jakarta-commons/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/LayoutTag.java
  
  Index: LayoutTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/LayoutTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LayoutTag.java    24 Jan 2003 22:53:33 -0000      1.3
  +++ LayoutTag.java    26 Feb 2003 12:53:36 -0000      1.4
  @@ -93,7 +93,7 @@
        */
       public Layout getLayout() {
           Object bean = getBean();
  -        if ( bean instanceof Layout ) {
  +        if (bean instanceof Layout) {
               return (Layout) bean;
           }
           return null;
  @@ -105,26 +105,30 @@
       /**
        * Either defines a variable or adds the current component to the parent
        */
  -    protected void processBean(String var, Object bean) throws JellyTagException {
  +    protected void processBean(String var, Object bean)
  +        throws JellyTagException {
           super.processBean(var, bean);
  -        
  +
           Widget parent = getParentWidget();
  +
           if (parent instanceof Composite) {
               Composite composite = (Composite) parent;
               composite.setLayout(getLayout());
  -        }
  -        else {
  +
  +        } else {
               throw new JellyTagException("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 JellyTagException {
  -            
  -        if (bean instanceof FillLayout && name.equals("type") && value instanceof 
String) {
  +
  +        if (bean instanceof FillLayout
  +            && name.equals("type")
  +            && value instanceof String) {
               int style = SwtHelper.parseStyle(SWT.class, (String) value);
               return new Integer(style);
           }
  
  
  
  1.4       +11 -13    
jakarta-commons/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/LayoutTagSupport.java
  
  Index: LayoutTagSupport.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/LayoutTagSupport.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LayoutTagSupport.java     24 Jan 2003 22:53:33 -0000      1.3
  +++ LayoutTagSupport.java     26 Feb 2003 12:53:36 -0000      1.4
  @@ -113,10 +113,9 @@
       public void setVar(String var) {
           this.var = var;
       }
  -    
  +
       // Implementation methods
       //-------------------------------------------------------------------------     
               
  -
       /**
        * Either defines a variable or adds the current component to the parent
        */
  @@ -125,22 +124,21 @@
               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 JellyTagException {
  -            
  +    protected void setBeanProperties(Object bean, Map attributes) throws 
JellyTagException {
  +
           if (bean != null) {
               Class theClass = bean.getClass();
  -            for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext(); 
) {
  +            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);
  -                
  +
                   try {
                       // lets first see if there's a field available
                       Field field = theClass.getField(name);
  @@ -149,8 +147,7 @@
                               value = ConvertUtils.convert((String) value, 
field.getType());
                           }
                           field.set(bean, value);
  -                    }
  -                    else {
  +                    } else {
                           BeanUtils.setProperty(bean, name, value);
                       }
                   } catch (NoSuchFieldException e) {
  @@ -163,7 +160,7 @@
               }
           }
       }
  -    
  +
       /**
        * Provides a strategy method that allows values to be converted,
        * particularly to support integer enumerations and String representations.
  @@ -173,7 +170,8 @@
        * @param value the value of the property
        * @return the new value
        */
  -    protected Object convertValue(Object bean, String name, Object value) throws 
JellyTagException {
  +    protected Object convertValue(Object bean, String name, Object value)
  +        throws JellyTagException {
           return value;
       }
   
  
  
  
  1.10      +228 -234  
jakarta-commons/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/WidgetTag.java
  
  Index: WidgetTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/WidgetTag.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- WidgetTag.java    20 Feb 2003 18:14:53 -0000      1.9
  +++ WidgetTag.java    26 Feb 2003 12:53:36 -0000      1.10
  @@ -90,240 +90,234 @@
    */
   public class WidgetTag extends UseBeanTag {
   
  -     /** The Log to which logging calls will be made. */
  -     private static final Log log = LogFactory.getLog(WidgetTag.class);
  +    /** The Log to which logging calls will be made. */
  +    private static final Log log = LogFactory.getLog(WidgetTag.class);
   
  -     private Widget parent;
  -     private int style = SWT.NULL;
  +    protected Widget parent;
  +    private int style = SWT.NULL;
   
  -     public WidgetTag(Class widgetClass) {
  -             super(widgetClass);
  -     }
  -
  -     public WidgetTag(Class widgetClass, int style) {
  -             super(widgetClass);
  -             this.style = style;
  -     }
  -
  -     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() {
  -             if (parent == null) {
  -                     WidgetTag tag = (WidgetTag) 
findAncestorWithClass(WidgetTag.class);
  -                     if (tag != null) {
  -                             parent = tag.getWidget();
  -                     }
  -             }
  -             return parent;
  -     }
  -
  -     // Tag interface
  -     //-------------------------------------------------------------------------
  -     public void doTag(XMLOutput output) throws JellyTagException {
  -             Map attributes = getAttributes();
  -             Object parent = attributes.remove("parent");
  -             if (parent != null) {
  -                     if (parent instanceof Widget) {
  -                             this.parent = (Widget) parent;
  -                     } else {
  -                             throw new JellyTagException(
  -                                     "The parent attribute is not a Widget, it is 
of type: "
  -                                             + parent.getClass().getName()
  -                                             + " value: "
  -                                             + parent);
  -                     }
  -             }
  -             super.doTag(output);
  -     }
  -
  -     // Implementation methods
  -     //-------------------------------------------------------------------------    
                
  -
  -     /**
  -      * Factory method to create a new widget
  -      */
  -     protected Object newInstance(
  -             Class theClass,
  -             Map attributes,
  -             XMLOutput output)
  -             throws JellyTagException {
  -             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;
  -     }
  -
  -     /* 
  -      * @see 
org.apache.commons.jelly.tags.core.UseBeanTag#setBeanProperties(java.lang.Object, 
java.util.Map)
  -      */
  -     protected void setBeanProperties(Object bean, Map attributes)
  -             throws JellyTagException {
  -
  -             if (bean instanceof Control) {
  -                     Control control = (Control) bean;
  -
  -                     // Special handling of size property as the Control object 
breaks the
  -                     // JavaBean naming conventions by overloading the setSize() 
method      
  -                     Object size = attributes.remove("size");
  -                     setSize(control, size);
  -
  -                     // Special handling of color property as the Control object 
breaks the
  -                     // JavaBean naming conventions by overloading the 
setBackground() or setForeground() method     
  -                     Object colorValue = attributes.remove("background");
  -                     Color background = getColor(control, colorValue);
  -                     control.setBackground(background);
  -                     
  -                     colorValue = attributes.remove("foreground");
  -                     Color foreground = getColor(control, colorValue);
  -                     control.setForeground(foreground);
  -
  -             }
  -
  -             super.setBeanProperties(bean, attributes);
  -     }
  -
  -     /**
  -      * Get a color for the control                  
  -      * @param control
  -      * @param colorValue
  -      */
  -     protected Color getColor(Control control, Object colorValue) {
  -             Color color = null;
  -             if (colorValue != null) {
  -                     RGB rgb = null;
  -                     if (color instanceof Color) {
  -                             color = (Color) colorValue;
  -                     } else {
  -                             rgb = 
ColorConverter.getInstance().parse(colorValue.toString());
  -                             color = new Color(control.getDisplay(), rgb);
  -                     }
  -             }
  -             return color;
  -     }
  -
  -     /**
  -      * set the size of the control          
  -      * @param control
  -      * @param size
  -      */
  -     protected void setSize(Control control, Object size) {
  -             Point point = null;
  -             if (size != null) {
  -                     if (size instanceof Point) {
  -                             point = (Point) size;
  -                     } else {
  -                             point = 
PointConverter.getInstance().parse(size.toString());
  -                     }
  -                     control.setSize(point);
  -             }
  -             
  -     }
  -
  -     /**
  -      * 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) {
  -             // set the content that will be scrolled if the parent is a 
ScrolledComposite
  -             if (parent instanceof ScrolledComposite && widget instanceof Control) {
  -                     ScrolledComposite scrolledComposite = (ScrolledComposite) 
parent;
  -                     scrolledComposite.setContent((Control) 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 JellyTagException {
  -             if (theClass == null) {
  -                     throw new JellyTagException("No Class available to create the 
new widget");
  -             }
  -
  -             try {
  -                     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();
  -             } catch (NoSuchMethodException e) {
  -                     throw new JellyTagException(e);
  -             } catch (InstantiationException e) {
  -                     throw new JellyTagException(e);
  -             } catch (IllegalAccessException e) {
  -                     throw new JellyTagException(e);
  -             } catch (InvocationTargetException e) {
  -                     throw new JellyTagException(e);
  -             }
  -     }
  -
  -     /**
  -      * Creates the SWT style code for the current attributes
  -      * @return the SWT style code
  -      */
  -     protected int getStyle(Map attributes) throws JellyTagException {
  -             String text = (String) attributes.remove("style");
  -             if (text != null) {
  -                     return SwtHelper.parseStyle(SWT.class, text);
  -             }
  -             return style;
  -     }
  +    public WidgetTag(Class widgetClass) {
  +        super(widgetClass);
  +    }
  +
  +    public WidgetTag(Class widgetClass, int style) {
  +        super(widgetClass);
  +        this.style = style;
  +    }
  +
  +    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() {
  +
  +        if (parent == null) {
  +            WidgetTag tag = (WidgetTag) findAncestorWithClass(WidgetTag.class);
  +            if (tag != null) {
  +                return tag.getWidget();
  +            }
  +        }
  +
  +        return parent;
  +    }
  +
  +    // Tag interface
  +    //-------------------------------------------------------------------------
  +    public void doTag(XMLOutput output) throws JellyTagException {
  +        Map attributes = getAttributes();
  +        Object parent = attributes.remove("parent");
  +        if (parent != null) {
  +            if (parent instanceof Widget) {
  +                this.parent = (Widget) parent;
  +            } else {
  +                throw new JellyTagException(
  +                    "The parent attribute is not a Widget, it is of type: "
  +                        + parent.getClass().getName()
  +                        + " value: "
  +                        + parent);
  +            }
  +        }
  +        super.doTag(output);
  +    }
  +
  +    // Implementation methods
  +    //-------------------------------------------------------------------------     
               
  +
  +    /**
  +     * Factory method to create a new widget
  +     */
  +    protected Object newInstance(Class theClass, Map attributes, XMLOutput output)
  +        throws JellyTagException {
  +        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;
  +    }
  +
  +    /* 
  +     * @see 
org.apache.commons.jelly.tags.core.UseBeanTag#setBeanProperties(java.lang.Object, 
java.util.Map)
  +     */
  +    protected void setBeanProperties(Object bean, Map attributes) throws 
JellyTagException {
  +
  +        if (bean instanceof Control) {
  +            Control control = (Control) bean;
  +
  +            // Special handling of size property as the Control object breaks the
  +            // JavaBean naming conventions by overloading the setSize() method      
 
  +            Object size = attributes.remove("size");
  +            setSize(control, size);
  +
  +            // Special handling of color property as the Control object breaks the
  +            // JavaBean naming conventions by overloading the setBackground() or 
setForeground() method      
  +            Object colorValue = attributes.remove("background");
  +            Color background = getColor(control, colorValue);
  +            control.setBackground(background);
  +
  +            colorValue = attributes.remove("foreground");
  +            Color foreground = getColor(control, colorValue);
  +            control.setForeground(foreground);
  +        }
  +
  +        super.setBeanProperties(bean, attributes);
  +    }
  +
  +    /**
  +     * Get a color for the control           
  +     * @param control
  +     * @param colorValue
  +     */
  +    protected Color getColor(Control control, Object colorValue) {
  +        Color color = null;
  +        if (colorValue != null) {
  +            RGB rgb = null;
  +            if (color instanceof Color) {
  +                color = (Color) colorValue;
  +            } else {
  +                rgb = ColorConverter.getInstance().parse(colorValue.toString());
  +                color = new Color(control.getDisplay(), rgb);
  +            }
  +        }
  +        return color;
  +    }
  +
  +    /**
  +     * set the size of the control           
  +     * @param control
  +     * @param size
  +     */
  +    protected void setSize(Control control, Object size) {
  +        Point point = null;
  +        if (size != null) {
  +            if (size instanceof Point) {
  +                point = (Point) size;
  +            } else {
  +                point = PointConverter.getInstance().parse(size.toString());
  +            }
  +            control.setSize(point);
  +        }
  +
  +    }
  +
  +    /**
  +     * 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(Object parent, Widget widget) throws 
JellyTagException {
  +        // set the content that will be scrolled if the parent is a 
ScrolledComposite
  +        if (parent instanceof ScrolledComposite && widget instanceof Control) {
  +            ScrolledComposite scrolledComposite = (ScrolledComposite) parent;
  +            scrolledComposite.setContent((Control) 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 JellyTagException {
  +        if (theClass == null) {
  +            throw new JellyTagException("No Class available to create the new 
widget");
  +        }
  +
  +        try {
  +            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();
  +        } catch (NoSuchMethodException e) {
  +            throw new JellyTagException(e);
  +        } catch (InstantiationException e) {
  +            throw new JellyTagException(e);
  +        } catch (IllegalAccessException e) {
  +            throw new JellyTagException(e);
  +        } catch (InvocationTargetException e) {
  +            throw new JellyTagException(e);
  +        }
  +    }
  +
  +    /**
  +     * Creates the SWT style code for the current attributes
  +     * @return the SWT style code
  +     */
  +    protected int getStyle(Map attributes) throws JellyTagException {
  +        String text = (String) attributes.remove("style");
  +        if (text != null) {
  +            return SwtHelper.parseStyle(SWT.class, text);
  +        }
  +        return style;
  +    }
   }
  
  
  
  1.2       +1 -1      
jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/wizard/WizardDialogTag.java
  
  Index: WizardDialogTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/wizard/WizardDialogTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WizardDialogTag.java      26 Feb 2003 11:00:41 -0000      1.1
  +++ WizardDialogTag.java      26 Feb 2003 12:53:36 -0000      1.2
  @@ -62,7 +62,7 @@
   import org.apache.commons.jelly.Script;
   import org.apache.commons.jelly.XMLOutput;
   import org.apache.commons.jelly.tags.core.UseBeanTag;
  -import org.apache.commons.jelly.tags.jface.ApplicationWindowTag;
  +import org.apache.commons.jelly.tags.jface.window.ApplicationWindowTag;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.eclipse.jface.wizard.IWizard;
  
  
  
  1.4       +38 -4     
jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/JFaceTagLibrary.java
  
  Index: JFaceTagLibrary.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/JFaceTagLibrary.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JFaceTagLibrary.java      26 Feb 2003 11:00:42 -0000      1.3
  +++ JFaceTagLibrary.java      26 Feb 2003 12:53:36 -0000      1.4
  @@ -67,6 +67,7 @@
   import org.apache.commons.jelly.tags.jface.preference.FieldEditorTag;
   import org.apache.commons.jelly.tags.jface.preference.PreferenceDialogTag;
   import org.apache.commons.jelly.tags.jface.preference.PreferencePageTag;
  +import org.apache.commons.jelly.tags.jface.window.ApplicationWindowTag;
   import org.apache.commons.jelly.tags.jface.wizard.WizardDialogTag;
   import org.apache.commons.jelly.tags.jface.wizard.WizardPageTag;
   import org.apache.commons.jelly.tags.swt.SwtTagLibrary;
  @@ -242,7 +243,6 @@
           });
       }
   
  -
       /**
        * @param name
        * @param theClass
  @@ -257,7 +257,7 @@
               }
           });
       }
  -    
  +
       /**
        * @param name
        * @param theClass
  @@ -272,7 +272,7 @@
               }
           });
       }
  -    
  +
       protected void registerWizardPageTag(String name, final Class theClass) {
           registerTagFactory(name, new TagFactory() {
               /**
  @@ -283,6 +283,40 @@
               }
           });
       }
  -    
  +
  +    /**
  +     * Register a widget tag for the given name
  +     */
  +    protected void registerWidgetTag(String name, Class widgetClass) {
  +        registerWidgetTag(name, widgetClass, SWT.NULL);
  +    }
  +
  +    /**
  +     * Register a widget tag for the given name
  +     */
  +    protected void registerWidgetTag(String name, final Class widgetClass, final 
int style) {
  +        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 
JellyException {
  +                return new JFaceWidgetTag(widgetClass, style);
  +            }
  +        });
  +    }
  +
  +    /**
  +     * 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 
JellyException {
  +                return new JFaceLayoutTag(layoutClass);
  +            }
  +        });
  +    }
   
   }
  
  
  
  1.2       +4 -4      
jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/ViewerTag.java
  
  Index: ViewerTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/ViewerTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ViewerTag.java    26 Feb 2003 09:23:25 -0000      1.1
  +++ ViewerTag.java    26 Feb 2003 12:53:36 -0000      1.2
  @@ -84,16 +84,16 @@
       /**
        * @param widgetClass
        */
  -    public ViewerTag(Class widgetClass) {
  -        super(widgetClass);
  +    public ViewerTag(Class tagClass) {
  +        super(tagClass);
       }
   
       /**
        * @param widgetClass
        * @param style
        */
  -    public ViewerTag(Class widgetClass, int style) {
  -        super(widgetClass);
  +    public ViewerTag(Class tagClass, int style) {
  +        super(tagClass);
           this.style = style;
       }
   
  
  
  
  1.2       +1 -0      
jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/MenuManagerTag.java
  
  Index: MenuManagerTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/MenuManagerTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MenuManagerTag.java       26 Feb 2003 09:23:25 -0000      1.1
  +++ MenuManagerTag.java       26 Feb 2003 12:53:36 -0000      1.2
  @@ -67,6 +67,7 @@
   import org.apache.commons.jelly.MissingAttributeException;
   import org.apache.commons.jelly.XMLOutput;
   import org.apache.commons.jelly.tags.core.UseBeanTag;
  +import org.apache.commons.jelly.tags.jface.window.ApplicationWindowTag;
   import org.eclipse.jface.action.MenuManager;
   import org.eclipse.jface.window.ApplicationWindow;
   import org.eclipse.jface.window.Window;
  
  
  
  1.1                  
jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/JFaceWidgetTag.java
  
  Index: JFaceWidgetTag.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 [EMAIL PROTECTED]
   *
   * 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.jface;
  
  import org.apache.commons.jelly.JellyTagException;
  import org.apache.commons.jelly.Tag;
  import org.apache.commons.jelly.tags.jface.window.ApplicationWindowImpl;
  import org.apache.commons.jelly.tags.jface.window.ApplicationWindowTag;
  import org.apache.commons.jelly.tags.jface.wizard.WizardPageTag;
  import org.apache.commons.jelly.tags.swt.WidgetTag;
  import org.eclipse.jface.window.Window;
  import org.eclipse.swt.widgets.Composite;
  import org.eclipse.swt.widgets.Widget;
  
  /**
   * Implementation of SWT WidgetTag  
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]">Christiaan ten Klooster</a> 
   */
  public class JFaceWidgetTag extends WidgetTag implements Tag {
  
      /**
       * @param widgetClass
       */
      public JFaceWidgetTag(Class widgetClass) {
          super(widgetClass);
      }
  
      /**
       * @param widgetClass
       * @param style
       */
      public JFaceWidgetTag(Class widgetClass, int style) {
          super(widgetClass, style);
      }
  
      /* 
       * @see 
org.apache.commons.jelly.tags.swt.WidgetTag#attachWidgets(java.lang.Object, 
org.eclipse.swt.widgets.Widget)
       */
      protected void attachWidgets(Object parent, Widget widget) throws 
JellyTagException {
          super.attachWidgets(parent, widget);
  
          // set Parent composite of wizard page
          if (getParent() instanceof WizardPageTag) {
              WizardPageTag tag = (WizardPageTag) getParent();
              if (tag.getWizardPageImpl().getParentControl() == null) {
                  if (widget instanceof Composite) {
                      tag.getWizardPageImpl().setParentComposite((Composite) widget);
                  } else {
                      throw new JellyTagException("First child of a <wizardPage> must 
be of type Composite");
                  }
              }
          }
      }
  
      /* 
       * @see org.apache.commons.jelly.tags.swt.WidgetTag#getParentWidget()
       */
      public Widget getParentWidget() {
          parent = super.getParentWidget();
  
          if (parent == null && getParent() instanceof WizardPageTag) {
              WizardPageTag tag = (WizardPageTag) getParent();
              if (tag != null) {
                  WizardPageTag.WizardPageImpl page = tag.getWizardPageImpl();
                  return page.getControl();
              }
          }
  
          if (parent == null) {
              ApplicationWindowTag tag =
                  (ApplicationWindowTag) 
findAncestorWithClass(ApplicationWindowTag.class);
              if (tag != null) {
                  Window window = tag.getWindow();
                  if (window != null && window instanceof ApplicationWindowImpl) {
                      return ((ApplicationWindowImpl) window).getContents();
                  }
              }
          }
  
          return parent;
      }
  
  }
  
  
  
  1.1                  
jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/JFaceImageTag.java
  
  Index: JFaceImageTag.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 [EMAIL PROTECTED]
   *
   * 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.jface;
  
  import org.apache.commons.jelly.JellyTagException;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.jelly.tags.jface.window.ApplicationWindowImpl;
  import org.apache.commons.jelly.tags.jface.window.ApplicationWindowTag;
  import org.apache.commons.jelly.tags.swt.ImageTag;
  import org.eclipse.jface.window.Window;
  import org.eclipse.swt.graphics.Image;
  import org.eclipse.swt.widgets.Widget;
  
  /**
   * Implementation of SWT ImageTag
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]">Christiaan ten Klooster</a> 
   */
  public class JFaceImageTag extends ImageTag {
  
      /**
       * @return the parent window 
       */
      public Window getParentWindow() {
          ApplicationWindowTag tag =
              (ApplicationWindowTag) findAncestorWithClass(ApplicationWindowTag.class);
          if (tag != null) {
              return tag.getWindow();
          }
          return null;
      }
  
      /**
       * Set default image Window
       * @param window
       * @param image
       */
      private void setWindowImage(Window window, Image image) {
          Window.setDefaultImage(image);
      }
  
      /* 
       * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
       */
      public void doTag(XMLOutput output) throws JellyTagException {
  
          // invoke by body just in case some nested tag configures me
          invokeBody(output);
  
          Widget parent = getParentWidget();
          Window window = null;
          if (parent == null) {
              window = getParentWindow();
              if (window != null && window instanceof ApplicationWindowImpl) {
                  parent = ((ApplicationWindowImpl) window).getContents();
              }
          }
  
          if (parent == null && window == null) {
              throw new JellyTagException("This tag must be nested within a Widget or 
a Window");
          }
  
          Image image = new Image(parent.getDisplay(), getSrc());
          if (window != null) {
              setWindowImage(window, image);
          } else {
              setWidgetImage(parent, image);
          }
  
      }
  
  }
  
  
  
  1.1                  
jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/JFaceLayoutTag.java
  
  Index: JFaceLayoutTag.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 [EMAIL PROTECTED]
   *
   * 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.jface;
  
  import org.apache.commons.jelly.JellyTagException;
  import org.apache.commons.jelly.tags.jface.window.ApplicationWindowImpl;
  import org.apache.commons.jelly.tags.jface.window.ApplicationWindowTag;
  import org.apache.commons.jelly.tags.swt.LayoutTag;
  import org.eclipse.jface.window.Window;
  import org.eclipse.swt.widgets.Composite;
  import org.eclipse.swt.widgets.Widget;
  
  /**
   * Implementation of SWT LayoutTag
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]">Christiaan ten Klooster</a> 
   */
  public class JFaceLayoutTag extends LayoutTag {
  
      /**
       * @param layoutClass
       */
      public JFaceLayoutTag(Class layoutClass) {
          super(layoutClass);
          // TODO Auto-generated constructor stub
      }
  
      /* (non-Javadoc)
       * @see 
org.apache.commons.jelly.tags.core.UseBeanTag#processBean(java.lang.String, 
java.lang.Object)
       */
      protected void processBean(String var, Object bean) throws JellyTagException {
  
          Widget parent = getParentWidget();
          if (parent == null) { // perhaps parent is a Window
              Window window = getParentWindow();
              if (window != null && window instanceof ApplicationWindowImpl) {
                  parent = ((ApplicationWindowImpl) window).getContents();
              }
          }
  
          if (parent instanceof Composite) {
              Composite composite = (Composite) parent;
              composite.setLayout(getLayout());
  
          } else {
              throw new JellyTagException("This tag must be nested within a composite 
widget tag");
          }
  
      }
      
      /**
       * @return the parent window 
       */
      public Window getParentWindow() {
          ApplicationWindowTag tag =
              (ApplicationWindowTag) findAncestorWithClass(ApplicationWindowTag.class);
          if (tag != null) {
              return tag.getWindow();
          }
          return null;
      }
  }
  
  
  
  
  
  1.1                  
jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/JFaceLayoutDataTag.java
  
  Index: JFaceLayoutDataTag.java
  ===================================================================
  /*
   * Created on Feb 26, 2003
   *
   * To change this generated comment go to 
   * Window>Preferences>Java>Code Generation>Code Template
   */
  package org.apache.commons.jelly.tags.jface;
  
  import org.apache.commons.jelly.JellyTagException;
  import org.apache.commons.jelly.tags.jface.window.ApplicationWindowImpl;
  import org.apache.commons.jelly.tags.jface.window.ApplicationWindowTag;
  import org.apache.commons.jelly.tags.swt.LayoutDataTag;
  import org.eclipse.jface.window.Window;
  import org.eclipse.swt.widgets.Control;
  import org.eclipse.swt.widgets.Widget;
  
  /**
   * Implementation of SWT LayoutDataTag
   *  
   * @author <a href="mailto:[EMAIL PROTECTED]">Christiaan ten Klooster</a> 
   */
  public class JFaceLayoutDataTag extends LayoutDataTag {
  
      /**
       * @param layoutDataClass
       */
      public JFaceLayoutDataTag(Class layoutDataClass) {
          super(layoutDataClass);
      }
  
      /* (non-Javadoc)
       * @see 
org.apache.commons.jelly.tags.core.UseBeanTag#processBean(java.lang.String, 
java.lang.Object)
       */
      protected void processBean(String var, Object bean) throws JellyTagException {
          Widget parent = getParentWidget();
          Window window = null;
          if (parent == null) {
              window = getParentWindow();
              if (window != null && window instanceof ApplicationWindowImpl) {
                  parent = ((ApplicationWindowImpl) window).getContents();
              }
          }
  
          if (parent instanceof Control) {
              Control control = (Control) parent;
              control.setLayoutData(getBean());
          } else {
              throw new JellyTagException("This tag must be nested within a control 
widget tag");
          }
      }
  
      /**
       * @return the parent window 
       */
      public Window getParentWindow() {
          ApplicationWindowTag tag =
              (ApplicationWindowTag) findAncestorWithClass(ApplicationWindowTag.class);
          if (tag != null) {
              return tag.getWindow();
          }
          return null;
      }
  
  }
  
  
  
  1.1                  
jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/window/ApplicationWindowTag.java
  
  Index: ApplicationWindowTag.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 [EMAIL PROTECTED]
   *
   * 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.jface.window;
  
  import java.util.Map;
  
  import org.apache.commons.jelly.JellyTagException;
  import org.apache.commons.jelly.MissingAttributeException;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.jelly.tags.core.UseBeanTag;
  import org.eclipse.jface.window.Window;
  import org.eclipse.swt.SWT;
  import org.eclipse.swt.widgets.Shell;
  
  /**
   * This tag creates an JFace ApplicationWindow
   *  
   * @author <a href="mailto:[EMAIL PROTECTED]">Christiaan ten Klooster</a>
   */
  public class ApplicationWindowTag extends UseBeanTag {
  
      private Shell parent;
      private int style = SWT.NULL;
      
      /**
       * @param widgetClass
       */
      public ApplicationWindowTag(Class tagClass) {
          super(tagClass);
      }
  
      /* 
       * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
       */
      public void doTag(XMLOutput output)
          throws MissingAttributeException, JellyTagException {
          Map attributes = getAttributes();
          Object parent = attributes.remove("parent");
          if (parent != null) {
              if (parent instanceof Shell) {
                  this.parent = (Shell) parent;
              } else {
                  throw new JellyTagException(
                      "The parent attribute is not a Shell, it is of type: "
                          + parent.getClass().getName()
                          + " value: "
                          + parent);
              }
          }
          super.doTag(output);
      }
  
      /* 
       * @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 JellyTagException {
  
          return new ApplicationWindowImpl(parent);
      }
  
  
      /**
       * @return the visible window, if there is one.
       */
      public Window getWindow() {
          Object bean = getBean();
          if (bean instanceof Window) {
              return (Window) bean;
          }
          return null;
      }
      
  }
  
  
  
  1.1                  
jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/window/ApplicationWindowImpl.java
  
  Index: ApplicationWindowImpl.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 [EMAIL PROTECTED]
   *
   * 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.jface.window;
  
  import org.eclipse.jface.window.ApplicationWindow;
  import org.eclipse.swt.SWT;
  import org.eclipse.swt.widgets.Control;
  import org.eclipse.swt.widgets.Shell;
  
  /**
   * This is the default implementation for a ApplicationWindowTag
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]">Christiaan ten Klooster</a> 
   */
  public class ApplicationWindowImpl extends ApplicationWindow {
  
      /**
       * @param shell
       */
      public ApplicationWindowImpl(Shell parentShell) {
  
          super(parentShell);
  
          // default at all
          addMenuBar();
          addStatusLine();
          addToolBar(SWT.NULL);
  
          setBlockOnOpen(true);
  
          // create window 
          create();
      }
  
      /* 
       * override to make public
       * @see org.eclipse.jface.window.Window#getContents()
       */
      public Control getContents() {
          return super.getContents();
      }
  
  }
  
  
  
  1.2       +1 -1      
jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/preference/PreferenceDialogTag.java
  
  Index: PreferenceDialogTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/preference/PreferenceDialogTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PreferenceDialogTag.java  26 Feb 2003 10:26:09 -0000      1.1
  +++ PreferenceDialogTag.java  26 Feb 2003 12:53:37 -0000      1.2
  @@ -61,7 +61,7 @@
   import org.apache.commons.jelly.JellyTagException;
   import org.apache.commons.jelly.XMLOutput;
   import org.apache.commons.jelly.tags.core.UseBeanTag;
  -import org.apache.commons.jelly.tags.jface.ApplicationWindowTag;
  +import org.apache.commons.jelly.tags.jface.window.ApplicationWindowTag;
   import org.eclipse.jface.preference.PreferenceDialog;
   import org.eclipse.jface.preference.PreferenceManager;
   import org.eclipse.swt.widgets.Shell;
  
  
  
  1.2       +16 -15    
jakarta-commons/jelly/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/jface/JFaceDemo.jelly
  
  Index: JFaceDemo.jelly
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/jelly/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/jface/JFaceDemo.jelly,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JFaceDemo.jelly   26 Feb 2003 09:23:26 -0000      1.1
  +++ JFaceDemo.jelly   26 Feb 2003 12:53:37 -0000      1.2
  @@ -1,32 +1,33 @@
   <?xml version="1.0"?>
  -<j:jelly xmlns:j="jelly:core" xmlns="jelly:swt" xmlns:log="jelly:log">
  +<j:jelly xmlns:j="jelly:core" xmlns="jelly:jface" xmlns:log="jelly:log">
   
     <applicationWindow var="mainapp">
   
  -     <menuManager text="File">
  +             <menuManager text="File">
                        <action text="Test">
  -                                     <log:error> Very Nice !!!</log:error>
  +                             <log:info> Very Nice !!!</log:info>
                        </action>
                        <separator />
  -                     <action text="Check me" checked="true" />
  -     </menuManager>
  +                     
  +                     <action text="Check me" checked="true">
  +                             <log:info>I've been checked</log:info>
  +                     </action>
  +             </menuManager>
                
  -     <menuManager text="Edit">
  +             <menuManager text="Edit">
                        <action text="Say Hi Statusbar">
                                  ${mainapp.setStatus('Hello ...')} 
                        </action>
  -     </menuManager>
  +             </menuManager>
        
  -<!-- 
  -     <fillLayout type="vertical"/>   
  --->
  -
  -     <label text="A big red label 1" background="204, 0, 0"/>
  -     <label text="I can barelly read this ;-(" foreground="#f2f2f2" />
  -     <label text="It sure looks like the dutch flag ;-)" foreground="#ffffff" 
background="0, 0, 153" />              
  +             <fillLayout type="vertical"/>   
  +     
  +             <label text="A big red label 1" background="204, 0, 0"/>
  +             <label text="I can barelly read this ;-(" foreground="#f2f2f2" />
  +             <label text="It sure looks like the dutch flag ;-)" 
foreground="#ffffff" background="0, 0, 153" />              
        
     </applicationWindow>
  -
  +  
     ${mainapp.MenuBarManager.updateAll(true)} 
     ${mainapp.open()}
   
  
  
  
  1.1                  
jakarta-commons/jelly/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/jface/JFaceDemo.java
  
  Index: JFaceDemo.java
  ===================================================================
  /*
  * ====================================================================
  *
  * 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 [EMAIL PROTECTED]
  *
  * 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/>.
  * 
  */
  package org.apache.commons.jelly.tags.jface;
  
  import java.net.URL;
  
  import org.apache.commons.jelly.JellyContext;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.jelly.tags.jface.JFaceTagLibrary;
  
  /**
   * @author <a href="mailto:[EMAIL PROTECTED]">Christiaan ten Klooster</a> 
   */
  public class JFaceDemo {
  
      public static void main(String[] args) {
          try {
            
              JellyContext context = new JellyContext();
              
              /** @todo zap the following line once the Jelly core has this default */
              context.registerTagLibrary("jelly:jface", new JFaceTagLibrary());
              
              URL url = JFaceDemo.class.getResource("JFaceDemo.jelly");
              
              XMLOutput output = XMLOutput.createXMLOutput(System.out, true);
              context.runScript( url, output );
              output.flush();
  
          } 
          catch (Exception e) {
              e.printStackTrace();
          }
  
      }
  
  }
  
  
  
  1.5       +1 -2      jakarta-commons/jelly/jelly-tags/jface/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jelly/jelly-tags/jface/maven.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- maven.xml 26 Feb 2003 11:00:41 -0000      1.4
  +++ maven.xml 26 Feb 2003 12:53:37 -0000      1.5
  @@ -13,9 +13,8 @@
        <!-- demos -->
     <goal name="demo" prereqs="create-classpath"
                description="Runs a JellyJFace demo">
  -    <java classname="org.apache.commons.jelly.Jelly" fork="yes">
  +    <java classname="org.apache.commons.jelly.tags.jface.JFaceDemo" fork="yes">
         <classpath refid="test.classpath"/>
  -      <arg value="src/test/org/apache/commons/jelly/tags/jface/JFaceDemo.jelly"/>
       </java>
     </goal>
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to