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 10:26:10 GMT
jstrachan    2003/02/26 02:26:10

  Modified:    jelly/jelly-tags/jface maven.xml project.xml
               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/preference
                        PreferenceDialogTag.java PreferencePageTag.java
                        FieldEditorTag.java
               jelly/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/jface/preference
                        PreferenceDemo.java PreferenceDemo.jelly
  Log:
  Applied patches supplied by Christiaan ten Klooster for properties editing
  
  Revision  Changes    Path
  1.1                  jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/preference/PreferenceDialogTag.java
  
  Index: PreferenceDialogTag.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.preference;
  
  import java.util.Map;
  
  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.eclipse.jface.preference.PreferenceDialog;
  import org.eclipse.jface.preference.PreferenceManager;
  import org.eclipse.swt.widgets.Shell;
  
  /**
   * This Tag creates a JFace PreferenceDialog
   * 
   * @author <a href="mailto:ckl@dacelo.nl">Christiaan ten Klooster</a> 
   */
  public class PreferenceDialogTag extends UseBeanTag {
  
      public PreferenceDialogTag(Class arg0) {
          super(arg0);
      }
  
      /**
       * @return PreferenceDialog
       */
      public PreferenceDialog getPreferenceDialog() {
          Object bean = getBean();
          if (bean instanceof PreferenceDialog) {
              return (PreferenceDialog) bean;
          }
          return null;
      }
  
      /**
       * @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();
          }
      }
  
      /* 
       * @see org.apache.commons.jelly.tags.core.UseBeanTag#newInstance(java.lang.Class, java.util.Map,
org.apache.commons.jelly.XMLOutput)
       */
      protected Object newInstance(Class arg0, Map arg1, XMLOutput arg2) throws JellyTagException
{
          PreferenceManager pm = new PreferenceManager();
          return new PreferenceDialog(getShell(), pm);
      }
  
  }
  
  
  
  1.1                  jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/preference/PreferencePageTag.java
  
  Index: PreferencePageTag.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.preference;
  
  import java.io.IOException;
  
  import org.apache.commons.jelly.JellyTagException;
  import org.apache.commons.jelly.MissingAttributeException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.eclipse.jface.preference.FieldEditor;
  import org.eclipse.jface.preference.FieldEditorPreferencePage;
  import org.eclipse.jface.preference.IPreferenceStore;
  import org.eclipse.jface.preference.PreferenceDialog;
  import org.eclipse.jface.preference.PreferenceNode;
  import org.eclipse.jface.preference.PreferenceStore;
  import org.eclipse.swt.widgets.Composite;
  
  /**
   * This Tag creates a JFace PreferencePage
   * 
   * Provides a concrete preference store implementation based on an internal java.util.Properties
object
   * 
   * @author <a href="mailto:ckl@dacelo.nl">Christiaan ten Klooster</a> 
   */
  public class PreferencePageTag extends TagSupport {
  
      /**
       * Implementation of a FieldEditorPreferencePage
       * method createFieldEditors is called on Dialog.open()
       */
      public class PreferencePageImpl extends FieldEditorPreferencePage {
          private PreferenceStore preferenceStore;
  
          public PreferencePageImpl(String title) {
              super(title, FieldEditorPreferencePage.GRID);
              try {
                  preferenceStore = new PreferenceStore(filename);
                  preferenceStore.load();
                  setPreferenceStore(preferenceStore);
              } catch (IOException e) {
                  log.error(e);
              }
          }
  
          public void addField(FieldEditor editor) {
              super.addField(editor);
          }
  
          protected void createFieldEditors() {
              try {
                  invokeBody(output);
              } catch (JellyTagException e) {
                  log.error(e);
              }
          }
  
          public Composite getFieldEditorParent() {
              return super.getFieldEditorParent();
          }
  
          public IPreferenceStore getPreferenceStore() {
              return preferenceStore;
          }
      }
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(PreferencePageTag.class);
      
      /** Filename of the store */
      private String filename;
  
      /** Jelly XMLOutput */
      private XMLOutput output;
      
      /** Current PreferencePageImpl */
      private PreferencePageImpl page;
      
      /** Title of both PreferenceNode and PreferencePage */ 
      private String title;
  
      /* 
       * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
       */
      public void doTag(XMLOutput output) throws JellyTagException {
          // check location
          PreferenceDialogTag dialogTag =
              (PreferenceDialogTag) findAncestorWithClass(PreferenceDialogTag.class);
          if (dialogTag == null) {
              throw new JellyTagException("This tag must be nested within a <preferenceDialog>");
          }
  
          // check for missing attributes
          if (filename == null) {
              throw new MissingAttributeException("filename");
          }
          if (title == null) {
              throw new MissingAttributeException("title");
          }
  
          // build new PreferenceNode with same title as the PreferencePage
          PreferenceDialog dialog = dialogTag.getPreferenceDialog();
          PreferenceNode node = new PreferenceNode(title);
  
          // build new PreferencePage
          page = new PreferencePageImpl(title);
  
          // add node to PreferenceManager
          node.setPage(page);
          dialog.getPreferenceManager().addToRoot(node);
  
          // used by PreferencePageImpl
          this.output = output;
      }
  
      /**
       * Get the PreferencePageImpl
       * @return PreferencePageImpl
       */
      public PreferencePageImpl getPreferencePageImpl() {
          return page;
      }
  
      /**
       * Sets the filename.
       * @param filename The filename to set
       */
      public void setFilename(String filename) {
          this.filename = filename;
      }
  
      /**
       * Sets the title.
       * @param title The title to set
       */
      public void setTitle(String title) {
          this.title = title;
      }
  
  }
  
  
  
  1.1                  jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface/preference/FieldEditorTag.java
  
  Index: FieldEditorTag.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.preference;
  
  import java.lang.reflect.Constructor;
  import java.lang.reflect.InvocationTargetException;
  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.preference.FieldEditor;
  import org.eclipse.swt.widgets.Composite;
  
  /**
   * This Tag creates a JFace FieldEditor
   * 
   * @author <a href="mailto:ckl@dacelo.nl">Christiaan ten Klooster</a> 
   */
  public class FieldEditorTag extends UseBeanTag {
  
      public FieldEditorTag(Class arg0) {
          super(arg0);
      }
  
      /* 
       * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
       */
      public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException
{
          PreferencePageTag tag = (PreferencePageTag) findAncestorWithClass(PreferencePageTag.class);
          if (tag == null) {
              throw new JellyTagException("This tag must be nested inside a <preferencePage>");
          }
  
          // get new instance of FieldEditor
          PreferencePageTag.PreferencePageImpl page = tag.getPreferencePageImpl();
          getAttributes().put("parentComposite", page.getFieldEditorParent());
  
          // add fieldEditor to PreferencePage
          Object fieldEditor = newInstance(getDefaultClass(), getAttributes(), output);
          if (fieldEditor instanceof FieldEditor) {
              page.addField((FieldEditor) fieldEditor);
          }
  
      }
  
      /* 
       * @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 {
  
          if (theClass == null) {
              throw new JellyTagException("No Class available to create the FieldEditor");
          }
  
          String name = (String) attributes.get("name");
          if (name == null) {
              throw new MissingAttributeException("name");
          }
  
          String labelText = (String) attributes.get("labelText");
          if (labelText == null) {
              throw new MissingAttributeException("labelText");
          }
  
          Composite parentComposite = (Composite) attributes.get("parentComposite");
          if (parentComposite == null) {
              throw new MissingAttributeException("parentComposite");
          }
  
          // let's try to call a constructor 
          try {
              Class[] types = { String.class, String.class, Composite.class };
              Constructor constructor = theClass.getConstructor(types);
              if (constructor != null) {
                  Object[] arguments = { name, labelText, parentComposite };
                  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);
          }
      }
  
  }
  
  
  
  1.3       +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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- maven.xml	26 Feb 2003 09:14:23 -0000	1.2
  +++ maven.xml	26 Feb 2003 10:26:10 -0000	1.3
  @@ -12,10 +12,17 @@
   
   	<!-- demos -->
     <goal name="demo" prereqs="create-classpath"
  -		description="Runs a JellySWT demo">
  +		description="Runs a JellyJFace demo">
       <java classname="org.apache.commons.jelly.Jelly" fork="yes">
         <classpath refid="test.classpath"/>
         <arg value="src/test/org/apache/commons/jelly/tags/jface/JFaceDemo.jelly"/>
  +    </java>
  +  </goal>
  +
  +  <goal name="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>
   
  
  
  
  1.2       +5 -1      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- project.xml	20 Feb 2003 18:00:40 -0000	1.1
  +++ project.xml	26 Feb 2003 10:26:10 -0000	1.2
  @@ -45,11 +45,15 @@
       
   		<!-- jface libraries -->
       <dependency>
  -      <id>eclipse+runtime</id>
  +      <id>eclipse+boot</id>
         <version>2.1.0</version>
       </dependency>
       <dependency>
         <id>eclipse+jface</id>
  +      <version>2.1.0</version>
  +    </dependency>
  +    <dependency>
  +      <id>eclipse+runtime</id>
         <version>2.1.0</version>
       </dependency>
       
  
  
  
  1.1                  jakarta-commons/jelly/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/jface/preference/PreferenceDemo.java
  
  Index: PreferenceDemo.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.preference;
  
  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 PreferenceDemo {
  
      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 = PreferenceDemo.class.getResource("PreferenceDemo.jelly");
              
              XMLOutput output = XMLOutput.createXMLOutput(System.out, true);
              context.runScript( url, output );
              output.flush();
  
          } 
          catch (Exception e) {
              e.printStackTrace();
          }
  
      }
  
  }
  
  
  
  1.1                  jakarta-commons/jelly/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/jface/preference/PreferenceDemo.jelly
  
  Index: PreferenceDemo.jelly
  ===================================================================
  <?xml version="1.0"?>
  <j:jelly xmlns:j="jelly:core" xmlns="jelly:jface" xmlns:log="jelly:log">
  
    <applicationWindow var="mainapp">
    	
    	<preferenceDialog var="pd">
  				
  			<preferencePage title="General settings" filename="settings.props">
  				<booleanFieldEditor name="var1" labelText="It's boolean" />
  				<colorFieldEditor name="var2" labelText="MainColor" />
  				<directoryFieldEditor name="var3" labelText="Directory" />
  				<fileFieldEditor name="var4" labelText="File" />
  				<fontFieldEditor name="var5" labelText="Font" />					
  				<integerFieldEditor name="var6" labelText="Integer" />					
  				<stringFieldEditor name="var7" labelText="String" />	
  			</preferencePage>	
  				
  			<preferencePage title="Personal settings" filename="personal-settings.props" >
  				<stringFieldEditor name="var8" labelText="String1" />			
  				<stringFieldEditor name="var9" labelText="String2" />								
  			</preferencePage>
  
  	</preferenceDialog>		
  
  		
    </applicationWindow>
  
   
    ${pd.open()}	
  
   
  
  </j:jelly>
  
  
  
  1.2       +91 -38    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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JFaceTagLibrary.java	26 Feb 2003 09:23:25 -0000	1.1
  +++ JFaceTagLibrary.java	26 Feb 2003 10:26:10 -0000	1.2
  @@ -64,13 +64,23 @@
   import org.apache.commons.jelly.JellyException;
   import org.apache.commons.jelly.Tag;
   import org.apache.commons.jelly.impl.TagFactory;
  +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.swt.SwtTagLibrary;
   import org.eclipse.jface.action.Separator;
  -import org.eclipse.jface.window.ApplicationWindow;
  +import org.eclipse.jface.preference.BooleanFieldEditor;
  +import org.eclipse.jface.preference.ColorFieldEditor;
  +import org.eclipse.jface.preference.DirectoryFieldEditor;
  +import org.eclipse.jface.preference.FileFieldEditor;
  +import org.eclipse.jface.preference.FontFieldEditor;
  +import org.eclipse.jface.preference.IntegerFieldEditor;
  +import org.eclipse.jface.preference.StringFieldEditor;
   import org.eclipse.jface.viewers.CheckboxTreeViewer;
   import org.eclipse.jface.viewers.TableTreeViewer;
   import org.eclipse.jface.viewers.TableViewer;
   import org.eclipse.jface.viewers.TreeViewer;
  +import org.eclipse.jface.window.ApplicationWindow;
   import org.eclipse.swt.SWT;
   import org.xml.sax.Attributes;
   
  @@ -92,9 +102,7 @@
   
           // Event tags
           registerTag("doubleClickListener", DoubleClickListenerTag.class);
  -        registerTag(
  -            "selectionChangedListener",
  -            SelectionChangedListenerTag.class);
  +        registerTag("selectionChangedListener", SelectionChangedListenerTag.class);
   
           // Window tags
           registerWindowTag("applicationWindow", ApplicationWindow.class);
  @@ -107,6 +115,42 @@
   
           // ContributionItem tags
           registerContributionItemTag("separator", Separator.class);
  +
  +        // Wizard tags
  +        //registerWizardDialogTag("wizardDialog", WizardDialog.class);
  +        //registerWizardTag("wizard", Wizard.class);
  +        //registerWizardPageTag("wizardPage", WizardPage.class);
  +
  +        // preference tags
  +        registerPreferenceDialogTag("preferenceDialog", PreferenceDialogTag.class);
  +        registerTag("preferencePage", PreferencePageTag.class);
  +
  +        registerFieldEditorTag("booleanFieldEditor", BooleanFieldEditor.class);
  +        registerFieldEditorTag("colorFieldEditor", ColorFieldEditor.class);
  +        registerFieldEditorTag("directoryFieldEditor", DirectoryFieldEditor.class);
  +        registerFieldEditorTag("fileFieldEditor", FileFieldEditor.class);
  +        registerFieldEditorTag("fontFieldEditor", FontFieldEditor.class);
  +        registerFieldEditorTag("integerFieldEditor", IntegerFieldEditor.class);
  +        //registerFieldEditorTag("radioGroupFieldEditor", RadioGroupFieldEditor.class);
  +        //registerFieldEditorTag("stringButtonFieldEditor", StringButtonFieldEditor.class);
  +        registerFieldEditorTag("stringFieldEditor", StringFieldEditor.class);
  +
  +    }
  +
  +    /**
  +     * @param string
  +     * @param class1
  +     */
  +    private void registerMenuManager(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 MenuManagerTag();
  +            }
  +        });
  +
       }
   
       /**
  @@ -126,33 +170,13 @@
        * @param widgetClass
        * @param style
        */
  -    protected void registerViewerTag(
  -        String name,
  -        final Class theclass,
  -        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 ViewerTag(theclass, style);
  -            }
  -        });
  -    }
  -
  -    /**
  -     * @param string
  -     * @param class1
  -     */
  -    private void registerMenuManager(String name, final Class theClass) {
  +    protected void registerViewerTag(String name, final Class theClass, 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 MenuManagerTag();
  +            public Tag createTag(String name, Attributes attributes) throws JellyException
{
  +                return new ViewerTag(theClass, style);
               }
           });
       }
  @@ -160,6 +184,7 @@
       /**
        * Register a widget tag for the given name
        *      
  +     * @param name
        * @param widgetClass
        * @param style
        */
  @@ -168,42 +193,70 @@
               /**
                * @see org.apache.commons.jelly.impl.TagFactory#createTag(java.lang.String,
org.xml.sax.Attributes)
                */
  -            public Tag createTag(String name, Attributes attributes)
  -                throws JellyException {
  +            public Tag createTag(String name, Attributes attributes) throws JellyException
{
                   return new ApplicationWindowTag(theClass);
               }
           });
       }
   
       /**
  -     * Register a widget tag for the given name
  +     * Register an action tag for the given name
        */
       protected void registerActionTag(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 {
  +            public Tag createTag(String name, Attributes attributes) throws JellyException
{
                   return new ActionTag(theClass);
               }
           });
       }
   
       /**
  -       * Register a widget tag for the given name
  +       * Register a contribution item tag for the given name
          */
  -    protected void registerContributionItemTag(
  -        String name,
  -        final Class theClass) {
  +    protected void registerContributionItemTag(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 {
  +            public Tag createTag(String name, Attributes attributes) throws JellyException
{
                   return new ContributionItemTag(theClass);
               }
           });
       }
  +
  +    /**
  +     * @param name
  +     * @param theClass
  +     */
  +    protected void registerPreferenceDialogTag(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 PreferenceDialogTag(theClass);
  +            }
  +        });
  +    }
  +
  +
  +    /**
  +     * @param name
  +     * @param theClass
  +     */
  +    protected void registerFieldEditorTag(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 FieldEditorTag(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