Coverage report

  %line %branch
org.apache.commons.jelly.tags.jface.JFaceWidgetTag
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;
 17  
 
 18  
 import org.apache.commons.jelly.JellyTagException;
 19  
 import org.apache.commons.jelly.Tag;
 20  
 import org.apache.commons.jelly.tags.jface.window.ApplicationWindowImpl;
 21  
 import org.apache.commons.jelly.tags.jface.window.ApplicationWindowTag;
 22  
 import org.apache.commons.jelly.tags.jface.wizard.WizardPageTag;
 23  
 import org.apache.commons.jelly.tags.swt.WidgetTag;
 24  
 import org.eclipse.jface.window.Window;
 25  
 import org.eclipse.swt.widgets.Composite;
 26  
 import org.eclipse.swt.widgets.Widget;
 27  
 
 28  
 /**
 29  
  * Implementation of SWT WidgetTag
 30  
  *
 31  
  * @author <a href="mailto:ckl@dacelo.nl">Christiaan ten Klooster</a>
 32  
  */
 33  
 public class JFaceWidgetTag extends WidgetTag implements Tag {
 34  
 
 35  
     /**
 36  
      * @param widgetClass
 37  
      */
 38  
     public JFaceWidgetTag(Class widgetClass) {
 39  0
         super(widgetClass);
 40  0
     }
 41  
 
 42  
     /**
 43  
      * @param widgetClass
 44  
      * @param style
 45  
      */
 46  
     public JFaceWidgetTag(Class widgetClass, int style) {
 47  0
         super(widgetClass, style);
 48  0
     }
 49  
 
 50  
     /*
 51  
      * @see org.apache.commons.jelly.tags.swt.WidgetTag#attachWidgets(java.lang.Object, org.eclipse.swt.widgets.Widget)
 52  
      */
 53  
     protected void attachWidgets(Object parent, Widget widget) throws JellyTagException {
 54  0
         super.attachWidgets(parent, widget);
 55  
 
 56  
         // set Parent composite of wizard page
 57  0
         if (getParent() instanceof WizardPageTag) {
 58  0
             WizardPageTag tag = (WizardPageTag) getParent();
 59  0
             if (tag.getWizardPageImpl().getParentControl() == null) {
 60  0
                 if (widget instanceof Composite) {
 61  0
                     tag.getWizardPageImpl().setParentComposite((Composite) widget);
 62  
                 } else {
 63  0
                     throw new JellyTagException("First child of a <wizardPage> must be of type Composite");
 64  
                 }
 65  
             }
 66  
         }
 67  0
     }
 68  
 
 69  
     /*
 70  
      * @see org.apache.commons.jelly.tags.swt.WidgetTag#getParentWidget()
 71  
      */
 72  
     public Widget getParentWidget() {
 73  0
         parent = super.getParentWidget();
 74  
 
 75  0
         if (parent == null && getParent() instanceof WizardPageTag) {
 76  0
             WizardPageTag tag = (WizardPageTag) getParent();
 77  0
             if (tag != null) {
 78  0
                 WizardPageTag.WizardPageImpl page = tag.getWizardPageImpl();
 79  0
                 return page.getControl();
 80  
             }
 81  
         }
 82  
 
 83  0
         if (parent == null) {
 84  0
             ApplicationWindowTag tag =
 85  
                 (ApplicationWindowTag) findAncestorWithClass(ApplicationWindowTag.class);
 86  0
             if (tag != null) {
 87  0
                 Window window = tag.getWindow();
 88  0
                 if (window != null && window instanceof ApplicationWindowImpl) {
 89  0
                     return ((ApplicationWindowImpl) window).getContents();
 90  
                 }
 91  
             }
 92  
         }
 93  
 
 94  0
         return parent;
 95  
     }
 96  
 
 97  
 }

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