Coverage Report - org.apache.tapestry.contrib.inspector.ViewTabs
 
Classes in this File Line Coverage Branch Coverage Complexity
ViewTabs
0%
0/22
0%
0/4
1.25
 
 1  
 // Copyright 2004, 2005 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  
 
 15  
 package org.apache.tapestry.contrib.inspector;
 16  
 
 17  
 import org.apache.tapestry.BaseComponent;
 18  
 import org.apache.tapestry.IAsset;
 19  
 
 20  
 /**
 21  
  * Component of the {@link Inspector} page used to select the view.
 22  
  * 
 23  
  * @author Howard Lewis Ship
 24  
  */
 25  
 
 26  0
 public abstract class ViewTabs extends BaseComponent
 27  
 {
 28  0
     private static String[] _views =
 29  
     { View.SPECIFICATION, View.TEMPLATE, View.PROPERTIES, View.ENGINE };
 30  
 
 31  
     public String[] getViews()
 32  
     {
 33  0
         return _views;
 34  
     }
 35  
 
 36  
     public abstract void setView(String value);
 37  
 
 38  
     public abstract String getView();
 39  
 
 40  
     private IAsset getImageForView(boolean focus)
 41  
     {
 42  0
         Inspector inspector = (Inspector) getPage();
 43  
 
 44  0
         String view = getView();
 45  
 
 46  0
         boolean selected = view.equals(inspector.getView());
 47  
 
 48  0
         StringBuffer buffer = new StringBuffer(view);
 49  
 
 50  0
         if (selected)
 51  0
             buffer.append("_selected");
 52  
 
 53  0
         if (focus)
 54  0
             buffer.append("_focus");
 55  
 
 56  0
         String key = buffer.toString();
 57  
         
 58  0
         return (IAsset) getAssets().get(key);
 59  
     }
 60  
 
 61  
     public IAsset getViewImage()
 62  
     {
 63  0
         return getImageForView(false);
 64  
     }
 65  
 
 66  
     public IAsset getFocusImage()
 67  
     {
 68  0
         return getImageForView(true);
 69  
     }
 70  
 
 71  
     public IAsset getBannerImage()
 72  
     {
 73  0
         Inspector inspector = (Inspector) getPage();
 74  0
         String selectedView = inspector.getView();
 75  
         
 76  0
         String key = selectedView + "_banner";
 77  
         
 78  0
         return (IAsset) getAssets().get(key);
 79  
     }
 80  
 
 81  
     public void selectTab(String view)
 82  
     {
 83  0
         Inspector inspector = (Inspector) getPage();
 84  0
         inspector.setView(view);
 85  0
     }
 86  
 }