Coverage Report - org.apache.tapestry.dojo.html.Dialog
 
Classes in this File Line Coverage Branch Coverage Complexity
Dialog
0%
0/33
0%
0/10
1.278
 
 1  
 // Copyright Oct 16, 2006 The Apache Software Foundation
 2  
 //
 3  
 // Licensed under the Apache License, Version 2.0 (the "License");
 4  
 // you may not use this file except in compliance with the License.
 5  
 // You may obtain a copy of the License at
 6  
 //
 7  
 // http://www.apache.org/licenses/LICENSE-2.0
 8  
 //
 9  
 // Unless required by applicable law or agreed to in writing, software
 10  
 // distributed under the License is distributed on an "AS IS" BASIS,
 11  
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
 // See the License for the specific language governing permissions and
 13  
 // limitations under the License.
 14  
 package org.apache.tapestry.dojo.html;
 15  
 
 16  
 import org.apache.tapestry.IMarkupWriter;
 17  
 import org.apache.tapestry.IRequestCycle;
 18  
 import org.apache.tapestry.IScript;
 19  
 import org.apache.tapestry.TapestryUtils;
 20  
 import org.apache.tapestry.dojo.AbstractWidget;
 21  
 import org.apache.tapestry.json.JSONObject;
 22  
 import org.apache.tapestry.services.ResponseBuilder;
 23  
 
 24  
 import java.util.HashMap;
 25  
 import java.util.Map;
 26  
 
 27  
 
 28  
 /**
 29  
  * Implementation of dojo Dialog widget.
 30  
  * 
 31  
  */
 32  0
 public abstract class Dialog extends AbstractWidget
 33  
 {
 34  
     public abstract boolean isHidden();
 35  
     public abstract void setHidden(boolean hidden);
 36  
     
 37  
     public abstract String getBackgroundColor();
 38  
     
 39  
     public abstract float getOpacity();
 40  
     
 41  
     public abstract boolean getFollowScroll();
 42  
     
 43  
     public abstract boolean getCloseOnBackgroundClick();
 44  
     
 45  
     public abstract int getBlockDuration();
 46  
     
 47  
     public abstract int getLifeTime();
 48  
     
 49  
     public abstract String getToggle();
 50  
     
 51  
     public abstract int getToggleDuration();
 52  
 
 53  
     /**
 54  
      * If called will execute the client side widget checkSize() function to re-size
 55  
      * and re-center the widget.  This is useful in circumstances where you are updating
 56  
      * content within the dialog itself.
 57  
      */
 58  
     public void resize()
 59  
     {
 60  0
         setResizing(true);
 61  0
     }
 62  
 
 63  
     public void show()
 64  
     {
 65  0
         setHidden(false);
 66  0
     }
 67  
 
 68  
     public void hide()
 69  
     {
 70  0
         setHidden(true);
 71  0
     }
 72  
     
 73  
     /**
 74  
      * {@inheritDoc}
 75  
      */
 76  
     public void renderWidget(IMarkupWriter writer, IRequestCycle cycle)
 77  
     {
 78  0
         if (!cycle.isRewinding())
 79  
         {
 80  0
             writer.begin(getTemplateTagName()); // use element specified
 81  0
             renderIdAttribute(writer, cycle); // render id="" client id
 82  0
             renderInformalParameters(writer, cycle);
 83  
         }
 84  
         
 85  0
         renderBody(writer, cycle);
 86  
         
 87  0
         if (!cycle.isRewinding())
 88  0
             writer.end();
 89  
         
 90  0
         if (!cycle.isRewinding())
 91  
         {
 92  0
             JSONObject json = new JSONObject();
 93  0
             json.put("bgColor", getBackgroundColor());
 94  0
             json.put("bgOpacity", getOpacity());
 95  0
             json.put("followScroll", getFollowScroll());
 96  0
             json.put("closeOnBackgroundClick", getCloseOnBackgroundClick());
 97  0
             json.put("blockDuration", getBlockDuration());
 98  0
             json.put("lifeTime", getLifeTime());
 99  0
             json.put("toggle", getToggle());
 100  0
             json.put("toggleDuration", getToggleDuration());
 101  
 
 102  0
             Map parms = new HashMap();
 103  0
             parms.put("component", this);
 104  0
             parms.put("props", json.toString());
 105  
             
 106  0
             getScript().execute(this, cycle, TapestryUtils.getPageRenderSupport(cycle, this), parms);
 107  
 
 108  0
             if (isResizing())
 109  
             {
 110  0
                 if (!getResponseBuilder().isInitializationScriptAllowed(this))
 111  
                 {
 112  0
                     getResponseBuilder().updateComponent(getId());
 113  
                 }
 114  
 
 115  0
                 getResponseBuilder().addScriptAfterInitialization(this, "dojo.widget.byId('" + getClientId() + "').checkSize();");
 116  
             }
 117  
         }
 118  0
     }
 119  
 
 120  
     public abstract ResponseBuilder getResponseBuilder();
 121  
 
 122  
     public abstract boolean isResizing();
 123  
 
 124  
     public abstract void setResizing(boolean value);
 125  
 
 126  
     /** injected. */
 127  
     public abstract IScript getScript();
 128  
 }