1 13 package info.magnolia.cms.taglibs; 14 15 import info.magnolia.cms.gui.inline.BarMain; 16 import info.magnolia.cms.util.Resource; 17 18 import java.io.IOException ; 19 20 import javax.servlet.http.HttpServletRequest ; 21 import javax.servlet.jsp.tagext.TagSupport ; 22 23 import org.apache.commons.lang.StringUtils; 24 import org.apache.log4j.Logger; 25 26 27 32 public class MainBar extends TagSupport { 33 34 37 private static final long serialVersionUID = 222L; 38 39 42 private static Logger log = Logger.getLogger(MainBar.class); 43 44 private String paragraph; 45 46 private boolean adminButtonVisible; 47 48 51 public int doStartTag() { 52 return EVAL_BODY_INCLUDE; 53 } 54 55 58 public int doEndTag() { 59 63 try { 64 this.display(); 65 } 66 catch (Exception e) { 67 log.warn("Exception caught during display: " + e.getMessage(), e); } 69 return EVAL_PAGE; 70 } 71 72 78 private String getPath() { 79 HttpServletRequest request = (HttpServletRequest ) this.pageContext.getRequest(); 80 try { 81 return Resource.getCurrentActivePage(request).getHandle(); 82 } 83 catch (Exception re) { 84 return StringUtils.EMPTY; 85 } 86 } 87 88 96 public void setParFile(String type) { 97 this.setParagraph(type); 98 } 99 100 107 public void setParagraph(String s) { 108 this.paragraph = s; 109 } 110 111 114 private String getParagraph() { 115 return this.paragraph; 116 } 117 118 124 private void display() throws IOException { 125 HttpServletRequest request = (HttpServletRequest ) this.pageContext.getRequest(); 126 BarMain bar = new BarMain(request); 127 bar.setPath(this.getPath()); 128 bar.setParagraph(this.getParagraph()); 129 bar.setDefaultButtons(); 130 bar.placeDefaultButtons(); 131 bar.drawHtml(pageContext.getOut()); 132 } 133 134 public boolean isAdminButtonVisible() { 135 return this.adminButtonVisible; 136 } 137 138 public void setAdminButtonVisible(boolean adminButtonVisible) { 139 this.adminButtonVisible = adminButtonVisible; 140 } 141 142 145 public void release() { 146 super.release(); 147 this.paragraph = null; 148 this.adminButtonVisible = false; 149 } 150 } 151 | Popular Tags |