Coverage report

  %line %branch
org.apache.commons.jelly.tags.jface.preference.PreferenceDialogTag
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.preference;
 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.core.UseBeanTag;
 23  
 import org.apache.commons.jelly.tags.jface.window.ApplicationWindowTag;
 24  
 import org.eclipse.jface.preference.PreferenceDialog;
 25  
 import org.eclipse.jface.preference.PreferenceManager;
 26  
 import org.eclipse.swt.widgets.Shell;
 27  
 
 28  
 /**
 29  
  * This Tag creates a JFace PreferenceDialog
 30  
  *
 31  
  * @author <a href="mailto:ckl@dacelo.nl">Christiaan ten Klooster</a>
 32  
  */
 33  0
 public class PreferenceDialogTag extends UseBeanTag {
 34  
 
 35  
     public PreferenceDialogTag(Class arg0) {
 36  0
         super(arg0);
 37  0
     }
 38  
 
 39  
     /**
 40  
      * @return PreferenceDialog
 41  
      */
 42  
     public PreferenceDialog getPreferenceDialog() {
 43  0
         Object bean = getBean();
 44  0
         if (bean instanceof PreferenceDialog) {
 45  0
             return (PreferenceDialog) bean;
 46  
         }
 47  0
         return null;
 48  
     }
 49  
 
 50  
     /**
 51  
      * @return Shell
 52  
      * @throws JellyTagException
 53  
      */
 54  
     protected Shell getShell() throws JellyTagException {
 55  0
         ApplicationWindowTag tag =
 56  
             (ApplicationWindowTag) findAncestorWithClass(ApplicationWindowTag.class);
 57  
 
 58  0
         if (tag != null) {
 59  0
             return tag.getWindow().getShell();
 60  
 
 61  
         } else {
 62  0
             Map attributes = getAttributes();
 63  0
             Object parent = attributes.remove("parent");
 64  0
             if (parent instanceof Shell) {
 65  0
                 return (Shell) parent;
 66  
             } else {
 67  0
                 throw new JellyTagException("This tag must be nested inside a <applicationWindow> or have a parent of type Shell");
 68  
             }
 69  
         }
 70  
     }
 71  
 
 72  
     /*
 73  
      * @see org.apache.commons.jelly.tags.core.UseBeanTag#newInstance(java.lang.Class, java.util.Map, org.apache.commons.jelly.XMLOutput)
 74  
      */
 75  
     protected Object newInstance(Class arg0, Map arg1, XMLOutput arg2) throws JellyTagException {
 76  0
         PreferenceManager pm = new PreferenceManager();
 77  0
         return new PreferenceDialog(getShell(), pm);
 78  
     }
 79  
 
 80  
 }

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