Coverage report

  %line %branch
org.apache.commons.jelly.tags.jface.ViewerTag
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 java.util.Map;
 19  
 
 20  
 import org.apache.commons.jelly.JellyTagException;
 21  
 import org.apache.commons.jelly.XMLOutput;
 22  
 import org.apache.commons.jelly.tags.swt.WidgetTag;
 23  
 import org.eclipse.jface.viewers.Viewer;
 24  
 import org.eclipse.swt.SWT;
 25  
 import org.eclipse.swt.widgets.Composite;
 26  
 import org.eclipse.swt.widgets.Widget;
 27  
 
 28  
 /**
 29  
  * This tag creates an JFace Viewer
 30  
  *
 31  
  * @author <a href="mailto:ckl@dacelo.nl">Christiaan ten Klooster</a>
 32  
  */
 33  
 public class ViewerTag extends WidgetTag {
 34  
 
 35  
     private Composite parent;
 36  0
     private int style = SWT.NULL;
 37  
 
 38  
     /**
 39  
      * @param widgetClass
 40  
      */
 41  
     public ViewerTag(Class tagClass) {
 42  0
         super(tagClass);
 43  0
     }
 44  
 
 45  
     /**
 46  
      * @param widgetClass
 47  
      * @param style
 48  
      */
 49  
     public ViewerTag(Class tagClass, int style) {
 50  0
         super(tagClass);
 51  0
         this.style = style;
 52  0
     }
 53  
 
 54  
     /*
 55  
      * @see org.apache.commons.jelly.tags.core.UseBeanTag#newInstance(java.lang.Class, java.util.Map, org.apache.commons.jelly.XMLOutput)
 56  
      */
 57  
     protected Object newInstance(
 58  
         Class theClass,
 59  
         Map attributes,
 60  
         XMLOutput output)
 61  
         throws JellyTagException {
 62  
 
 63  0
         int style = getStyle(attributes);
 64  
 
 65  
         // now lets call the constructor with the parent
 66  0
         Widget parent = getParentWidget();
 67  0
         Viewer viewer = (Viewer) createWidget(theClass, parent, style);
 68  
 
 69  0
         return viewer;
 70  
     }
 71  
 
 72  
     /**
 73  
      * @return the visible viewer, if there is one.
 74  
      */
 75  
     public Viewer getViewer() {
 76  0
         Object bean = getBean();
 77  0
         if (bean instanceof Viewer) {
 78  0
             return (Viewer) bean;
 79  
         }
 80  0
         return null;
 81  
     }
 82  
 
 83  
 }

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