Coverage report

  %line %branch
org.apache.commons.jelly.tags.jface.MenuManagerTag
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.MissingAttributeException;
 22  
 import org.apache.commons.jelly.XMLOutput;
 23  
 import org.apache.commons.jelly.tags.core.UseBeanTag;
 24  
 import org.apache.commons.jelly.tags.jface.window.ApplicationWindowTag;
 25  
 import org.eclipse.jface.action.MenuManager;
 26  
 import org.eclipse.jface.window.ApplicationWindow;
 27  
 import org.eclipse.jface.window.Window;
 28  
 
 29  
 /**
 30  
  * This tag creates an JFace MenuManager
 31  
  *
 32  
  * @author <a href="mailto:ckl@dacelo.nl">Christiaan ten Klooster</a>
 33  
  */
 34  0
 public class MenuManagerTag extends UseBeanTag {
 35  
 
 36  
     private String text;
 37  
     private MenuManager mm;
 38  
 
 39  
     /**
 40  
      * @return the parent window which this widget will be added to.
 41  
      */
 42  
     public Window getParentWindow() {
 43  
 
 44  0
         ApplicationWindowTag tag =
 45  
             (ApplicationWindowTag) findAncestorWithClass(ApplicationWindowTag
 46  
                 .class);
 47  0
         if (tag != null) {
 48  0
             return tag.getWindow();
 49  
         }
 50  
 
 51  0
         return null;
 52  
     }
 53  
 
 54  
     /* (non-Javadoc)
 55  
      * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
 56  
      */
 57  
     public void doTag(XMLOutput output)
 58  
         throws MissingAttributeException, JellyTagException {
 59  
 
 60  0
         Map attributes = getAttributes();
 61  0
         text = attributes.remove("text").toString();
 62  
 
 63  0
         if (text == null)
 64  0
             throw new MissingAttributeException("text attribute is missing");
 65  
 
 66  0
         mm = new MenuManager(text);
 67  
 
 68  0
         ApplicationWindow window = (ApplicationWindow) getParentWindow();
 69  0
         if (window != null) {
 70  0
             window.getMenuBarManager().add(mm);
 71  
         }
 72  
 
 73  
         // invoke by body just in case some nested tag configures me
 74  0
         invokeBody(output);
 75  0
     }
 76  
 
 77  
     /**
 78  
      * @return MenuManager
 79  
      */
 80  
     public MenuManager getMenuManager() {
 81  0
         return mm;
 82  
     }
 83  
 
 84  
 }

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