1 13 package info.magnolia.cms.gui.inline; 14 15 import info.magnolia.cms.beans.config.ContentRepository; 16 import info.magnolia.cms.gui.control.Button; 17 import info.magnolia.cms.i18n.MessagesManager; 18 import info.magnolia.cms.security.Permission; 19 import info.magnolia.cms.util.Resource; 20 21 import java.io.IOException ; 22 23 import javax.servlet.http.HttpServletRequest ; 24 import javax.servlet.jsp.JspWriter ; 25 26 import org.apache.commons.lang.StringUtils; 27 28 29 33 public class ButtonEdit extends Button { 34 35 String label = "buttons.edit"; 37 public ButtonEdit() { 38 } 39 40 public ButtonEdit(HttpServletRequest request) { 41 this.setRequest(request); 42 } 43 44 public ButtonEdit( 45 HttpServletRequest request, 46 String path, 47 String nodeCollectionName, 48 String nodeName, 49 String paragraph) { 50 this.setRequest(request); 51 this.setPath(path); 52 this.setNodeCollectionName(nodeCollectionName); 53 this.setNodeName(nodeName); 54 this.setParagraph(paragraph); 55 } 56 57 public void setDefaultOnclick(HttpServletRequest request) { 58 String nodeCollectionName = this.getNodeCollectionName(); 59 if (nodeCollectionName == null) { 60 nodeCollectionName = StringUtils.EMPTY; 61 } 62 String nodeName = this.getNodeName(); 63 if (nodeName == null) { 64 nodeName = StringUtils.EMPTY; 65 } 66 67 String repository = (String ) getRequest().getAttribute(info.magnolia.cms.core.Aggregator.REPOSITORY); 68 this.setOnclick("mgnlOpenDialog('" + this.getPath() 70 + "','" + nodeCollectionName 72 + "','" + nodeName 74 + "','" + this.getParagraph() 76 + "','" + repository 78 + "');"); } 80 81 public String getLabel() { 82 return MessagesManager.getWithDefault(label, label); 83 } 84 85 public void setLabel(String s) { 86 this.label = s; 87 } 88 89 97 public void drawHtml(JspWriter out) throws IOException { 98 if (this.getRequest() != null) { 99 boolean isGranted = Resource.getActivePage(this.getRequest()).isGranted(Permission.SET); 100 if (!Resource.showPreview(this.getRequest()) && isGranted) { 101 out.println(this.getHtml()); 102 } 103 } 104 } 105 } 106 | Popular Tags |