commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface JFaceTagLibrary.java
Date Wed, 26 Feb 2003 11:00:42 GMT
jstrachan    2003/02/26 03:00:42

  Modified:    jelly/jelly-tags/jface maven.xml project.xml
               jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt
                        SwtTagLibrary.java
               jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface
                        JFaceTagLibrary.java
  Added:       jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/wizard
                        WizardDialogTag.java WizardPageTag.java
               jelly/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/jface/wizard
                        WizardDemo.jelly WizardDemo.java
  Log:
  Applied patches supplied by Christiaan ten Klooster for wizard creation with JellyJFace
  
  Revision  Changes    Path
  1.1                  jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/wizard/WizardDialogTag.java
  
  Index: WizardDialogTag.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 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/>.
  * 
  */
  package org.apache.commons.jelly.tags.jface.wizard;
  
  import java.util.Map;
  
  import org.apache.commons.jelly.JellyTagException;
  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.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.eclipse.jface.wizard.IWizard;
  import org.eclipse.jface.wizard.Wizard;
  import org.eclipse.jface.wizard.WizardDialog;
  import org.eclipse.swt.widgets.Shell;
  
  /**
   *  This Tag creates a JFace WizardDialog
   *  
   * @author <a href="mailto:ckl@dacelo.nl">Christiaan ten Klooster</a> 
   */
  public class WizardDialogTag extends UseBeanTag {
  
      /**
       * Provide a public method getWizard
       */
      class WizardDialogImpl extends WizardDialog {
          public WizardDialogImpl(Shell parentShell, IWizard newWizard) {
              super(parentShell, newWizard);
          }
  
          public IWizard getWizard() {
              return super.getWizard();
          }
      }
  
      /**
        * Provide a Wizard implementation
        */
      class WizardImpl extends Wizard {
          public WizardImpl() {
              super();
              setNeedsProgressMonitor(true);
          }
  
          public boolean performCancel() {
              try {
                  if (performCancel != null) {
                      performCancel.run(context, output);
                  } else {
                      invokeBody(output);
                  }
              } catch (JellyTagException e) {
                  log.error(e);
                  return false;
              }
              return true;
          }
  
          public boolean performFinish() {
              try {
                  if (performFinish != null) {
                      performFinish.run(context, output);
                  } else {
                      invokeBody(output);
                  }
              } catch (JellyTagException e) {
                  log.error(e);
                  return false;
              }
              return true;
          }
      }
      
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(WizardDialogTag.class);
  
      /** Jelly XMLOutput */
      private XMLOutput output;
  
      /** Script to be executed on performCancel */
      private Script performCancel;
  
      /** Script to be executed on performFinish */
      private Script performFinish;
  
      /**
       * @param theClass
       */
      public WizardDialogTag(Class theClass) {
          super(theClass);
      }
  
      /* 
       * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
       */
      public void doTag(XMLOutput output) throws JellyTagException {
          super.doTag(output);
  
          if (getAttributes().get("performCancel") != null) {
              Object script = getAttributes().get("performCancel");
              if (script instanceof Script) {
                  performCancel = (Script) getAttributes().get("performCancel");
              } else {
                  throw new JellyTagException("Attributevalue " + script + " must be a Script");
              }
          }
  
          if (getAttributes().get("performFinish") != null) {
              Object script = getAttributes().get("performFinish");
              if (script instanceof Script) {
                  performFinish = (Script) getAttributes().get("performFinish");
              } else {
                  throw new JellyTagException("Attributevalue " + script + " must be a Script");
              }
          }
  
          this.output = output;
      }
  
      /**
       * @return Shell
       * @throws JellyTagException
       */
      protected Shell getShell() throws JellyTagException {
          ApplicationWindowTag tag =
              (ApplicationWindowTag) findAncestorWithClass(ApplicationWindowTag.class);
          if (tag == null) {
              throw new JellyTagException("This tag must be nested inside a <applicationWindow>");
          } else {
              return tag.getWindow().getShell();
          }
      }
  
      /**
       * @return WizardDialog
       */
      public WizardDialogImpl getWizardDialogImpl() {
          Object bean = getBean();
          if (bean instanceof WizardDialog) {
              return (WizardDialogImpl) bean;
          }
          return null;
      }
  
      /* 
       * @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 {
          Wizard wizard = new WizardImpl();
          return new WizardDialogImpl(getShell(), wizard);
      }
  
      /**
       * Sets the Script to be executed on performCancel.
       * @param performCancel The performCancel to set
       */
      public void setPerformCancel(Script performCancel) {
          this.performCancel = performCancel;
      }
  
      /**
       * Sets the Script to be executed on performFinish.
       * @param performFinish The performFinish to set
       */
      public void setPerformFinish(Script performFinish) {
          this.performFinish = performFinish;
      }
  
  }
  
  
  
  1.1                  jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/wizard/WizardPageTag.java
  
  Index: WizardPageTag.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 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/>.
  * 
  */
  package org.apache.commons.jelly.tags.jface.wizard;
  
  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.apache.commons.jelly.tags.jface.preference.PreferencePageTag;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.eclipse.jface.wizard.Wizard;
  import org.eclipse.jface.wizard.WizardPage;
  import org.eclipse.swt.widgets.Composite;
  import org.eclipse.swt.widgets.Control;
  
  /**
   *  This Tag creates a JFace WizardPage
   * 
   * @author <a href="mailto:ckl@dacelo.nl">Christiaan ten Klooster</a> 
   */
  public class WizardPageTag extends UseBeanTag {
  
      /**
       * Implementation of a WizardPage
       * method createControl is called on Dialog.open()
       */
      public class WizardPageImpl extends WizardPage {
          private Composite parentComposite;
  
          public WizardPageImpl(String title) {
              super(title);
          }
  
          public void createControl(Composite parent) {
              // set initial parent Control to avoid a NPE during invokeBody
              setControl(parent);
  
              // create page contents 
              try {
                  invokeBody(output);
              } catch (JellyTagException e) {
                  log.error(e);
              }
              
              // parentComposite should be first Composite child 
              if (parentComposite != null) {
                  setControl(parentComposite);
              }
          }
  
          public Control getParentControl() {
              return parentComposite;
          }
          public void setParentComposite(Composite parentComposite) {
              this.parentComposite = parentComposite;
          }
  
      }
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(PreferencePageTag.class);
  
      /** Jelly XMLOutput */
      private XMLOutput output;
  
      /**
       * @param theClass
       */
      public WizardPageTag(Class theClass) {
          super(theClass);
      }
  
      /* 
       * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
       */
      public void doTag(XMLOutput output) throws JellyTagException {
          // check location
          WizardDialogTag wizardTag = (WizardDialogTag) findAncestorWithClass(WizardDialogTag.class);
          if (wizardTag == null) {
              throw new JellyTagException("This tag must be nested within a <wizardDialog>");
          }
  
          // check for missing attributes
          String title = (String) getAttributes().get("title");
          if (title == null) {
              throw new MissingAttributeException("title");
          }
  
          // get WizardPageImpl
          WizardPageImpl page = new WizardPageImpl(title);
          setBean(page);
          setBeanProperties(page, getAttributes());
  
          String var = (String) getAttributes().get("var");
          processBean(var, page);
  
          // get Wizard 
          WizardDialogTag.WizardDialogImpl dialog = wizardTag.getWizardDialogImpl();
          Wizard wizard = (Wizard) dialog.getWizard();
  
          // add WizardPage to the Wizard
          wizard.addPage(page);
  
          // used by implementing page
          this.output = output;
      }
  
      /**
       * Get the WizardPageImpl
       * @return WizardPageImpl
       */
      public WizardPageImpl getWizardPageImpl() {
          Object bean = getBean();
          if (bean instanceof WizardPageImpl) {
              return (WizardPageImpl) bean;
          }
          return null;
      }
  
  }
  
  
  
  1.4       +8 -1      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- maven.xml	26 Feb 2003 10:26:10 -0000	1.3
  +++ maven.xml	26 Feb 2003 11:00:41 -0000	1.4
  @@ -19,9 +19,16 @@
       </java>
     </goal>
   
  -  <goal name="preferences" prereqs="create-classpath"
  +  <goal name="demo:preferences" prereqs="create-classpath"
   		description="Runs a Preferences demo">
       <java classname="org.apache.commons.jelly.tags.jface.preference.PreferenceDemo"
fork="yes">
  +      <classpath refid="test.classpath"/>
  +    </java>
  +  </goal>
  +
  +  <goal name="demo:wizard" prereqs="create-classpath"
  +		description="Runs a Wizard demo">
  +    <java classname="org.apache.commons.jelly.tags.jface.wizard.WizardDemo" fork="yes">
         <classpath refid="test.classpath"/>
       </java>
     </goal>
  
  
  
  1.3       +4 -0      jakarta-commons/jelly/jelly-tags/jface/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jelly/jelly-tags/jface/project.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- project.xml	26 Feb 2003 10:26:10 -0000	1.2
  +++ project.xml	26 Feb 2003 11:00:41 -0000	1.3
  @@ -69,6 +69,10 @@
         <id>commons-jelly+tags-log</id>
         <version>SNAPSHOT</version>
       </dependency>
  +    <dependency>
  +      <id>commons-jelly+tags-define</id>
  +      <version>SNAPSHOT</version>
  +    </dependency>
       	
       <!-- END for running demos -->
     </dependencies>
  
  
  
  1.8       +46 -13    jakarta-commons/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/SwtTagLibrary.java
  
  Index: SwtTagLibrary.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/SwtTagLibrary.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SwtTagLibrary.java	19 Feb 2003 07:24:40 -0000	1.7
  +++ SwtTagLibrary.java	26 Feb 2003 11:00:42 -0000	1.8
  @@ -61,27 +61,55 @@
    */
   package org.apache.commons.jelly.tags.swt;
   
  -import org.eclipse.swt.SWT;
  -import org.eclipse.swt.custom.*;
  -import org.eclipse.swt.graphics.Point;
  -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.beanutils.ConvertUtils;
  -
   import org.apache.commons.jelly.JellyException;
   import org.apache.commons.jelly.Tag;
   import org.apache.commons.jelly.TagLibrary;
   import org.apache.commons.jelly.impl.TagFactory;
  +import org.apache.commons.jelly.tags.swt.converters.ColorConverter;
   import org.apache.commons.jelly.tags.swt.converters.PointConverter;
  -
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  -
  +import org.eclipse.swt.SWT;
  +import org.eclipse.swt.custom.ScrolledComposite;
  +import org.eclipse.swt.custom.TableTree;
  +import org.eclipse.swt.custom.TableTreeItem;
  +import org.eclipse.swt.graphics.Color;
  +import org.eclipse.swt.graphics.Point;
  +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.Button;
  +import org.eclipse.swt.widgets.Canvas;
  +import org.eclipse.swt.widgets.Caret;
  +import org.eclipse.swt.widgets.Combo;
  +import org.eclipse.swt.widgets.Composite;
  +import org.eclipse.swt.widgets.CoolBar;
  +import org.eclipse.swt.widgets.CoolItem;
  +import org.eclipse.swt.widgets.Decorations;
  +import org.eclipse.swt.widgets.Group;
  +import org.eclipse.swt.widgets.Label;
  +import org.eclipse.swt.widgets.List;
  +import org.eclipse.swt.widgets.MenuItem;
  +import org.eclipse.swt.widgets.MessageBox;
  +import org.eclipse.swt.widgets.ProgressBar;
  +import org.eclipse.swt.widgets.Sash;
  +import org.eclipse.swt.widgets.Scale;
  +import org.eclipse.swt.widgets.Shell;
  +import org.eclipse.swt.widgets.Slider;
  +import org.eclipse.swt.widgets.TabFolder;
  +import org.eclipse.swt.widgets.TabItem;
  +import org.eclipse.swt.widgets.Table;
  +import org.eclipse.swt.widgets.TableColumn;
  +import org.eclipse.swt.widgets.TableItem;
  +import org.eclipse.swt.widgets.Text;
  +import org.eclipse.swt.widgets.ToolBar;
  +import org.eclipse.swt.widgets.ToolItem;
  +import org.eclipse.swt.widgets.Tracker;
  +import org.eclipse.swt.widgets.Tree;
  +import org.eclipse.swt.widgets.TreeItem;
   import org.xml.sax.Attributes;
   
   /** 
  @@ -98,6 +126,7 @@
       static {
           // register the various beanutils Converters from Strings to various SWT types

           ConvertUtils.register( new PointConverter(), Point.class );
  +        ConvertUtils.register( new ColorConverter(), Color.class );
       }
           
       public SwtTagLibrary() {
  @@ -160,6 +189,7 @@
   
           // other tags                    
           registerTag("image", ImageTag.class);
  +
       }
   
       /**
  @@ -240,4 +270,7 @@
               }
           );
       }
  +    
  +
  + 
   }
  
  
  
  1.1                  jakarta-commons/jelly/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/jface/wizard/WizardDemo.jelly
  
  Index: WizardDemo.jelly
  ===================================================================
  <?xml version="1.0"?>
  <j:jelly xmlns:j="jelly:core" xmlns="jelly:jface" xmlns:log="jelly:log" xmlns:define="jelly:define">
  
    <define:script var="onPerformFinish">
  		<log:error>onPerformFinish called ...</log:error>
    </define:script>
    
    <define:script var="onPerformCancel">
  		<log:error>onPerformCancel called ...</log:error>
    </define:script>  
    
    <applicationWindow var="mainapp">
    	
  		<wizardDialog var="wizardDialog" performFinish="${onPerformFinish}" performCancel="${onPerformCancel}">
  
  			<wizardPage var="wpage1" title="Step 1" description="Step 1 in this wizard, showing
page 1">
  				<composite>
  					<gridLayout numColumns="2" />
  					
  					<label text="Some input" />
  					<text />
  					
  					<label text="Label 1" />
  					<button text="Set Message">	
  						<onEvent type="Selection">
  							${wpage1.setMessage('Message: give me some more ...')}
  						</onEvent>
  					</button>
  					<label text="Label 2" />
  					<button text="Set Error Message">	
  						<onEvent type="Selection">
  							${wpage1.setErrorMessage('ErrorMessage: This step is not complete')}
  						</onEvent>						
  					</button>	
  					<label text="Label 3" />
  					<button text="Set Page Complete">	
  						<onEvent type="Selection">
  							${wpage1.setPageComplete(true)}
  						</onEvent>						
  					</button>
  					
  				</composite>
  			</wizardPage>	
  
  			
  			<wizardPage var="wpage2" title="Step 2" description="Step 2 in this wizard">
  				<composite>
  					<gridLayout numColumns="2" />
  					<label text="Label 3" />
  					<button text="Do nothing" />
  				</composite>
  			</wizardPage>	
  			
  		</wizardDialog>
  	
    </applicationWindow>
  
    ${wpage1.setPageComplete(false)}  
    ${wizardDialog.open()}  
  
  
  </j:jelly>
  
  
  
  
  1.1                  jakarta-commons/jelly/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/jface/wizard/WizardDemo.java
  
  Index: WizardDemo.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 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/>.
  * 
  */
  package org.apache.commons.jelly.tags.jface.wizard;
  
  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:ckl@dacelo.nl">Christiaan ten Klooster</a> 
   */
  public class WizardDemo {
  
      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 = WizardDemo.class.getResource("WizardDemo.jelly");
              
              XMLOutput output = XMLOutput.createXMLOutput(System.out, true);
              context.runScript( url, output );
              output.flush();
  
          } 
          catch (Exception e) {
              e.printStackTrace();
          }
  
      }
  
  }
  
  
  
  1.3       +32 -6     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JFaceTagLibrary.java	26 Feb 2003 10:26:10 -0000	1.2
  +++ JFaceTagLibrary.java	26 Feb 2003 11:00:42 -0000	1.3
  @@ -67,6 +67,8 @@
   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.wizard.WizardDialogTag;
  +import org.apache.commons.jelly.tags.jface.wizard.WizardPageTag;
   import org.apache.commons.jelly.tags.swt.SwtTagLibrary;
   import org.eclipse.jface.action.Separator;
   import org.eclipse.jface.preference.BooleanFieldEditor;
  @@ -117,14 +119,12 @@
           registerContributionItemTag("separator", Separator.class);
   
           // Wizard tags
  -        //registerWizardDialogTag("wizardDialog", WizardDialog.class);
  -        //registerWizardTag("wizard", Wizard.class);
  -        //registerWizardPageTag("wizardPage", WizardPage.class);
  +        registerWizardDialogTag("wizardDialog", WizardDialogTag.class);
  +        registerWizardPageTag("wizardPage", WizardPageTag.class);
   
  -        // preference tags
  +        // Preference tags
           registerPreferenceDialogTag("preferenceDialog", PreferenceDialogTag.class);
           registerTag("preferencePage", PreferencePageTag.class);
  -
           registerFieldEditorTag("booleanFieldEditor", BooleanFieldEditor.class);
           registerFieldEditorTag("colorFieldEditor", ColorFieldEditor.class);
           registerFieldEditorTag("directoryFieldEditor", DirectoryFieldEditor.class);
  @@ -257,6 +257,32 @@
               }
           });
       }
  +    
  +    /**
  +     * @param name
  +     * @param theClass
  +     */
  +    protected void registerWizardDialogTag(String name, final Class theClass) {
  +        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 WizardDialogTag(theClass);
  +            }
  +        });
  +    }
  +    
  +    protected void registerWizardPageTag(String name, final Class theClass) {
  +        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 WizardPageTag(theClass);
  +            }
  +        });
  +    }
  +    
   
   }
  -
  
  
  

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


Mime
View raw message