Coverage report

  %line %branch
org.apache.commons.jelly.tags.swing.DialogTag
7% 
60% 

 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.swing;
 17  
 
 18  
 import java.awt.Component;
 19  
 import java.awt.Container;
 20  
 import java.awt.Dialog;
 21  
 import java.awt.Frame;
 22  
 import java.util.Map;
 23  
 import javax.swing.JDialog;
 24  
 
 25  
 import org.apache.commons.jelly.JellyTagException;
 26  
 import org.apache.commons.jelly.XMLOutput;
 27  
 import org.apache.commons.jelly.tags.core.UseBeanTag;
 28  
 import org.apache.commons.logging.Log;
 29  
 import org.apache.commons.logging.LogFactory;
 30  
 
 31  
 /**
 32  
  * Creates a Swing Dialog.  A JDialog needs to have it's owner set in the constructor,
 33  
  * which is why this class is needed instead of just using a BeanFactory.
 34  
  *
 35  
  * @author Dave Pekarek Krohn
 36  
  * @version $Revision: 155420 $
 37  
  */
 38  
 public class DialogTag extends UseBeanTag implements ContainerTag {
 39  
 
 40  
     /** The Log to which logging calls will be made. */
 41  8
     private static final Log log = LogFactory.getLog(DialogTag.class);
 42  
 
 43  
     public DialogTag() {
 44  0
         super(JDialog.class);
 45  0
     }
 46  
 
 47  
     // Implementation methods
 48  
     //-------------------------------------------------------------------------
 49  
 
 50  
     /**
 51  
      * Creates a JDialog.  The constructor used depends on the value of the owner attribute.
 52  
      */
 53  
     protected Object newInstance(Class theClass, Map attributes, XMLOutput output)
 54  
     throws JellyTagException {
 55  0
         Object owner = attributes.remove( "owner" );
 56  0
         if (owner instanceof Frame) {
 57  0
             return new JDialog((Frame) owner);
 58  0
         } else if (owner instanceof Dialog) {
 59  0
             return new JDialog((Dialog) owner);
 60  
         } else {
 61  0
             return new JDialog();
 62  
         }
 63  
     }
 64  
 
 65  
     // ContainerTag interface
 66  
     //-------------------------------------------------------------------------
 67  
 
 68  
     /**
 69  
      * Adds a component to the dialog.
 70  
      */
 71  
     public void addChild(Component component, Object constraints) {
 72  0
         Container contentPane = ((JDialog) getBean()).getContentPane();
 73  0
         if (constraints != null) {
 74  0
             contentPane.add( component, constraints );
 75  
         } else {
 76  0
             contentPane.add( component );
 77  
         }
 78  0
     }
 79  
 }
 80  
 

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