Clover coverage report - angkor - 0.4
Coverage timestamp: ti okt 15 2002 22:32:48 CEST
file stats: LOC: 130   Methods: 13
NCLOC: 99   Classes: 1
Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover.
 
 Source file Conditionals Statements Methods TOTAL
Link.java 0% 0% 0% 0%
 1   
 /*
 2   
  * Angkor Web Framework
 3   
  *
 4   
  * Distributable under LGPL license.
 5   
  * See terms of license at gnu.org.
 6   
  */
 7   
 
 8   
 package com.tirsen.angkor.widget;
 9   
 
 10   
 import com.tirsen.angkor.Debug;
 11   
 import com.tirsen.angkor.RenderContext;
 12   
 import com.tirsen.angkor.View;
 13   
 import com.tirsen.angkor.event.Action;
 14   
 import com.tirsen.angkor.event.ActionListener;
 15   
 import com.tirsen.angkor.event.ActionSource;
 16   
 import com.tirsen.angkor.event.ActionSourceHelper;
 17   
 import org.apache.log4j.Category;
 18   
 
 19   
 import java.io.IOException;
 20   
 
 21   
 /**
 22   
  * @author $Author: tirsen $
 23   
  * @version $Revision: 1.5 $
 24   
  * <BR>
 25   
  * $Id: Link.java,v 1.5 2002/10/09 21:37:37 tirsen Exp $
 26   
  */
 27   
 public class Link extends Container implements ActionSource
 28   
 {
 29   
     private static final Category logger = Category.getInstance(Debug.LOGGER_NAME);
 30   
     private ActionSourceHelper actionSourceHelper = new ActionSourceHelper(this);
 31   
 
 32  0
     public static Link createActionLink(final Action action)
 33   
     {
 34  0
         TextLabel name = new TextLabel();
 35  0
         name.setModel(new ReadOnlyValueModel()
 36   
         {
 37  0
             public Object getValue()
 38   
             {
 39  0
                 return action.getValue(Action.NAME);
 40   
             }
 41   
         });
 42   
 
 43  0
         return createActionLink(action, name);
 44   
     }
 45   
 
 46  0
     public static Link createActionLink(Action action, View content)
 47   
     {
 48  0
         Link link = new Link();
 49  0
         link.setAction(action);
 50  0
         link.add(content);
 51  0
         return link;
 52   
     }
 53   
 
 54  0
     public Action getAction()
 55   
     {
 56  0
         return actionSourceHelper.getAction();
 57   
     }
 58   
 
 59  0
     public void setAction(Action action)
 60   
     {
 61  0
         actionSourceHelper.setAction(action);
 62   
     }
 63   
 
 64  0
     public void addActionListener(ActionListener listener)
 65   
     {
 66  0
         actionSourceHelper.addActionListener(listener);
 67   
     }
 68   
 
 69  0
     public void removeActionListener(ActionListener listener)
 70   
     {
 71  0
         actionSourceHelper.removeActionListener(listener);
 72   
     }
 73   
 
 74  0
     public void signalActionEvent()
 75   
     {
 76  0
         actionSourceHelper.signalActionEvent();
 77   
     }
 78   
 
 79  0
     public boolean isParsing()
 80   
     {
 81  0
         return true;
 82   
     }
 83   
 
 84  0
     private boolean isEnabled()
 85   
     {
 86  0
         return getAction() != null && getAction().isEnabled();
 87   
     }
 88   
 
 89  0
     public void render(RenderContext context) throws IOException
 90   
     {
 91  0
         if (isVisible())
 92   
         {
 93  0
             if (!isEnabled())
 94   
             {
 95   
                 // render as disabled
 96  0
                 context.startTag("SPAN id=\"" + uniqueId(context) + "\"");
 97  0
                 renderChildren(context);
 98  0
                 context.endTag("SPAN");
 99   
             }
 100   
             else
 101   
             {
 102  0
                 String url = context.requestURL(uniqueId(context) + "=clicked");
 103  0
                 context.startTag("A id=\"" + uniqueId(context) + "\" href=\"" + url + "\"");
 104  0
                 renderChildren(context);
 105  0
                 context.endTag("A");
 106  0
                 context.registerParsingComponent(this);
 107   
             }
 108  0
             context.println("&nbsp;");
 109   
         }
 110   
     }
 111   
 
 112  0
     public void parse(RenderContext context)
 113   
     {
 114  0
         super.parse(context);
 115  0
         if (context.getRequestParameter(getId()) != null)
 116   
         {
 117  0
             logger.debug("signalling event");
 118  0
             actionSourceHelper.signalActionEvent(context);
 119   
         }
 120   
     }
 121   
 
 122  0
     public static Link createImageStyle(Action action)
 123   
     {
 124  0
         Image removeImage = new Image();
 125  0
         removeImage.setSourceURL((String) action.getValue(Action.IMAGE_URL));
 126  0
         removeImage.setAlt((String) action.getValue(Action.DESCRIPTION));
 127  0
         return createActionLink(action, removeImage);
 128   
     }
 129   
 }
 130