Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 71311 invoked from network); 26 Feb 2003 11:00:52 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 26 Feb 2003 11:00:51 -0000 Received: (qmail 9628 invoked by uid 97); 26 Feb 2003 11:02:40 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org Received: (qmail 9621 invoked from network); 26 Feb 2003 11:02:39 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 26 Feb 2003 11:02:39 -0000 Received: (qmail 70764 invoked by uid 500); 26 Feb 2003 11:00:44 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 70722 invoked by uid 500); 26 Feb 2003 11:00:44 -0000 Received: (qmail 70690 invoked from network); 26 Feb 2003 11:00:44 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 26 Feb 2003 11:00:44 -0000 Received: (qmail 59974 invoked by uid 1315); 26 Feb 2003 11:00:42 -0000 Date: 26 Feb 2003 11:00:42 -0000 Message-ID: <20030226110042.59973.qmail@icarus.apache.org> From: jstrachan@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/jelly/jelly-tags/jface/src/java/org/apache/commons/jelly/tags/jface JFaceTagLibrary.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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 * . * */ 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 Christiaan ten Klooster */ 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 "); } 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 * . * */ 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 Christiaan ten Klooster */ 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 "); } // 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 @@ - + + + + + + 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 @@ commons-jelly+tags-log SNAPSHOT + + commons-jelly+tags-define + SNAPSHOT + 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 =================================================================== onPerformFinish called ... onPerformCancel called ...