1 15 package org.apache.tapestry.workbench.components; 16 17 import org.apache.tapestry.BaseComponent; 18 import org.apache.tapestry.IAsset; 19 import org.apache.tapestry.IRequestCycle; 20 import org.apache.tapestry.TapestryUtils; 21 import org.apache.tapestry.annotations.Asset; 22 import org.apache.tapestry.annotations.InjectAsset; 23 import org.apache.tapestry.annotations.InjectState; 24 import org.apache.tapestry.annotations.Message; 25 import org.apache.tapestry.event.PageBeginRenderListener; 26 import org.apache.tapestry.event.PageEvent; 27 import org.apache.tapestry.workbench.Visit; 28 29 35 36 public abstract class Border extends BaseComponent implements PageBeginRenderListener 37 { 38 39 43 44 private static String [] _tabOrder; 45 46 @InjectState("visit") 47 public abstract Visit getVisit(); 48 49 @Message 50 public abstract String getTabOrder(); 51 52 public void pageBeginRender(PageEvent event) 53 { 54 Visit visit = getVisit(); 55 56 setActivePageName(visit.getActiveTabName()); 57 58 if (_tabOrder == null) 59 _tabOrder = TapestryUtils.split(getTabOrder(), ' '); 60 } 61 62 66 67 public String [] getPageTabNames() 68 { 69 return _tabOrder; 70 } 71 72 public abstract void setPageName(String value); 73 74 public abstract String getPageName(); 75 76 public abstract void setActivePageName(String activePageName); 77 78 public abstract String getActivePageName(); 79 80 public boolean isActivePage() 81 { 82 return getPageName().equals(getActivePageName()); 83 } 84 85 public String getPageTitle() 86 { 87 90 return getMessages().getMessage(getPageName()); 91 } 92 93 96 @Asset("images/tab-active-left.gif") 97 public abstract IAsset getActiveLeft(); 98 99 @InjectAsset("inactiveLeft") 100 public abstract IAsset getInactiveLeft(); 101 102 @Asset("images/tab-active-mid.gif") 103 public abstract IAsset getActiveMid(); 104 105 @InjectAsset("inactiveMid") 106 public abstract IAsset getInactiveMid(); 107 108 @Asset("images/tab-active-right.gif") 109 public abstract IAsset getActiveRight(); 110 111 @InjectAsset("inactiveRight") 112 public abstract IAsset getInactiveRight(); 113 114 public IAsset getLeftTabAsset() 115 { 116 return isActivePage() ? getActiveLeft() : getInactiveLeft(); 117 } 118 119 public IAsset getMidTabAsset() 120 { 121 return isActivePage() ? getActiveMid() : getInactiveMid(); 122 } 123 124 public IAsset getRightTabAsset() 125 { 126 return isActivePage() ? getActiveRight() : getInactiveRight(); 127 } 128 129 public void selectPage(IRequestCycle cycle, String newPageName) 130 { 131 Visit visit = getVisit(); 132 133 visit.setActiveTabName(newPageName); 134 135 cycle.activate(newPageName); 136 } 137 } | Popular Tags |