1 23 package org.enhydra.barracuda.config; 24 25 import java.util.Arrays ; 26 27 import org.enhydra.barracuda.core.comp.*; 28 import org.apache.log4j.*; 29 30 35 public class TabsModel extends AbstractTemplateModel { 36 37 protected static final Logger logger = Logger.getLogger(TabsModel.class.getName()); 38 39 public final static String CUR_TAB = "CurrentTab"; 40 41 public final static String COMP_TAB_COMP = "CompTab_Comp"; 42 public final static String COMP_TAB_MODEL = "CompTab_Model"; 43 public final static String COMP_TAB_VIEW = "CompTab_View"; 44 public final static String COMP_TAB_REND = "CompTab_Renderer"; 45 public final static String DATA_TAB = "DataTab"; 46 public final static String DOM_TAB = "DomTab"; 47 public final static String EVENT_TAB = "EventTab"; 48 public final static String FORMS_TAB = "FormsTab"; 49 public final static String UTIL_TAB = "UtilTab"; 50 public final static String VIEW_TAB = "ViewTab"; 51 public final static String ABOUT_TAB = "AboutTab"; 52 53 public static String [] validTabs = new String [] {COMP_TAB_COMP, COMP_TAB_MODEL, COMP_TAB_VIEW, COMP_TAB_REND, DATA_TAB, DOM_TAB, EVENT_TAB, FORMS_TAB, UTIL_TAB, VIEW_TAB, ABOUT_TAB}; 54 55 protected BTemplate parent = null; 56 protected String curTab = null; 57 58 public TabsModel(BTemplate iparent) { 59 parent = iparent; 60 Arrays.sort(validTabs); 61 } 62 63 public String getName() { 65 return "Tabs"; 66 } 67 68 public void setCurrentTab(String tabName) { 70 if (tabName==null) return; 72 if (tabName.equals(curTab)) return; 73 int pos = Arrays.binarySearch(validTabs, tabName); 74 if (pos<0 || pos>=validTabs.length || !validTabs[pos].equals(tabName)) return; 75 76 if (logger.isDebugEnabled()) logger.debug("Setting curTab = "+tabName); 78 curTab = tabName; 79 if (parent!=null) parent.invalidate(); 80 } 81 82 public boolean processDirective(TemplateDirective td) { 84 if (td.getCommand().equals("Is_Visible")) { 85 String tab = td.getKeyName(); 86 if (curTab==null) setCurrentTab(tab); 87 if (logger.isDebugEnabled()) logger.debug("Checking to see if we can show "+tab+" ("+(tab.equals(curTab) ? "yes" : "no")+")"); 88 if (!tab.equals(curTab)) return false; } 90 return true; } 92 } | Popular Tags |