Coverage report

  %line %branch
org.apache.commons.jelly.tags.jface.wizard.WizardPageTag$WizardPageImpl
0% 
0% 

 1  
 /*
 2  
  * Copyright 2002,2004 The Apache Software Foundation.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.apache.commons.jelly.tags.jface.wizard;
 17  
 
 18  
 import org.apache.commons.jelly.JellyTagException;
 19  
 import org.apache.commons.jelly.MissingAttributeException;
 20  
 import org.apache.commons.jelly.XMLOutput;
 21  
 import org.apache.commons.jelly.tags.core.UseBeanTag;
 22  
 import org.apache.commons.jelly.tags.jface.preference.PreferencePageTag;
 23  
 import org.apache.commons.logging.Log;
 24  
 import org.apache.commons.logging.LogFactory;
 25  
 import org.eclipse.jface.wizard.Wizard;
 26  
 import org.eclipse.jface.wizard.WizardPage;
 27  
 import org.eclipse.swt.widgets.Composite;
 28  
 import org.eclipse.swt.widgets.Control;
 29  
 
 30  
 /**
 31  
  *  This Tag creates a JFace WizardPage
 32  
  *
 33  
  * @author <a href="mailto:ckl@dacelo.nl">Christiaan ten Klooster</a>
 34  
  */
 35  
 public class WizardPageTag extends UseBeanTag {
 36  
 
 37  
     /**
 38  
      * Implementation of a WizardPage
 39  
      * method createControl is called on Dialog.open()
 40  
      */
 41  
     public class WizardPageImpl extends WizardPage {
 42  
         private Composite parentComposite;
 43  
 
 44  0
         public WizardPageImpl(String title) {
 45  0
             super(title);
 46  0
         }
 47  
 
 48  
         public void createControl(Composite parent) {
 49  
             // set initial parent Control to avoid a NPE during invokeBody
 50  0
             setControl(parent);
 51  
 
 52  
             // create page contents
 53  
             try {
 54  0
                 invokeBody(output);
 55  0
             } catch (JellyTagException e) {
 56  0
                 log.error(e);
 57  
             }
 58  
 
 59  
             // parentComposite should be first Composite child
 60  0
             if (parentComposite != null) {
 61  0
                 setControl(parentComposite);
 62  
             }
 63  0
         }
 64  
 
 65  
         public Control getParentControl() {
 66  0
             return parentComposite;
 67  
         }
 68  
         public void setParentComposite(Composite parentComposite) {
 69  0
             this.parentComposite = parentComposite;
 70  0
         }
 71  
 
 72  
     }
 73  
 
 74  
     /** The Log to which logging calls will be made. */
 75  
     private static final Log log = LogFactory.getLog(PreferencePageTag.class);
 76  
 
 77  
     /** Jelly XMLOutput */
 78  
     private XMLOutput output;
 79  
 
 80  
     /**
 81  
      * @param theClass
 82  
      */
 83  
     public WizardPageTag(Class theClass) {
 84  
         super(theClass);
 85  
     }
 86  
 
 87  
     /*
 88  
      * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
 89  
      */
 90  
     public void doTag(XMLOutput output) throws JellyTagException {
 91  
         // check location
 92  
         WizardDialogTag wizardTag = (WizardDialogTag) findAncestorWithClass(WizardDialogTag.class);
 93  
         if (wizardTag == null) {
 94  
             throw new JellyTagException("This tag must be nested within a <wizardDialog>");
 95  
         }
 96  
 
 97  
         // check for missing attributes
 98  
         String title = (String) getAttributes().get("title");
 99  
         if (title == null) {
 100  
             throw new MissingAttributeException("title");
 101  
         }
 102  
 
 103  
         // get WizardPageImpl
 104  
         WizardPageImpl page = new WizardPageImpl(title);
 105  
         setBean(page);
 106  
         setBeanProperties(page, getAttributes());
 107  
 
 108  
         String var = (String) getAttributes().get("var");
 109  
         processBean(var, page);
 110  
 
 111  
         // get Wizard
 112  
         WizardDialogTag.WizardDialogImpl dialog = wizardTag.getWizardDialogImpl();
 113  
         Wizard wizard = (Wizard) dialog.getWizard();
 114  
 
 115  
         // add WizardPage to the Wizard
 116  
         wizard.addPage(page);
 117  
 
 118  
         // used by implementing page
 119  
         this.output = output;
 120  
     }
 121  
 
 122  
     /**
 123  
      * Get the WizardPageImpl
 124  
      * @return WizardPageImpl
 125  
      */
 126  
     public WizardPageImpl getWizardPageImpl() {
 127  
         Object bean = getBean();
 128  
         if (bean instanceof WizardPageImpl) {
 129  
             return (WizardPageImpl) bean;
 130  
         }
 131  
         return null;
 132  
     }
 133  
 
 134  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.