1 13 package info.magnolia.cms.gui.inline; 14 15 import info.magnolia.cms.beans.config.ContentRepository; 16 import info.magnolia.cms.gui.control.Bar; 17 import info.magnolia.cms.gui.control.Button; 18 import info.magnolia.cms.i18n.MessagesManager; 19 import info.magnolia.cms.security.Permission; 20 import info.magnolia.cms.util.Resource; 21 22 import java.io.IOException ; 23 24 import javax.servlet.http.HttpServletRequest ; 25 import javax.servlet.jsp.JspWriter ; 26 27 import org.apache.commons.lang.StringUtils; 28 29 30 34 public class BarNew extends Bar { 35 36 private Button buttonNew = new Button(); 37 38 public BarNew(HttpServletRequest request) { 39 this.setRequest(request); 40 } 41 42 45 public void setDefaultButtons() { 46 this.setButtonNew(); 47 } 48 49 52 public void placeDefaultButtons() { 53 if (this.getButtonNew() != null) { 54 this.getButtonsLeft().add(0, this.getButtonNew()); 55 } 56 } 57 58 public Button getButtonNew() { 59 return this.buttonNew; 60 } 61 62 public void setButtonNew(Button b) { 63 this.buttonNew = b; 64 } 65 66 public void setButtonNew() { 67 this.setButtonNew(this.getPath(), this.getNodeCollectionName(StringUtils.EMPTY), this 68 .getNodeName(StringUtils.EMPTY), this.getParagraph()); 69 } 70 71 78 public void setButtonNew(String path, String nodeCollectionName, String nodeName, String paragraph) { 79 Button b = new Button(); 80 b.setLabel(MessagesManager.getMessages().get("buttons.new")); 82 String repository = (String ) getRequest().getAttribute(info.magnolia.cms.core.Aggregator.REPOSITORY); 83 if (StringUtils.contains(paragraph, ',')) { 85 b.setOnclick("mgnlOpenDialog('" + path 87 + "','" + nodeCollectionName 89 + "','" + nodeName 91 + "','" + paragraph + "','" + repository 95 + "','.magnolia/dialogs/selectParagraph.html');"); } 97 else { 99 b.setOnclick("mgnlOpenDialog('" + path 101 + "','" + nodeCollectionName 103 + "','" + nodeName 105 + "','" + paragraph 107 + "','" + repository 109 + "');"); } 111 this.setButtonNew(b); 112 } 113 114 119 public void drawHtml(JspWriter out) throws IOException { 120 boolean isGranted = Resource.getActivePage(this.getRequest()).isGranted(Permission.SET); 121 if (!Resource.showPreview(this.getRequest()) && isGranted) { 122 this.setEvent("onmousedown", "mgnlMoveNodeEnd(this,'" + this.getPath() + "');"); this.setEvent("onmouseover", "mgnlMoveNodeHigh(this);"); this.setEvent("onmouseout", "mgnlMoveNodeReset(this);"); this.setId(this.getNodeCollectionName() + "__" + this.getNodeName()); out.println(this.getHtml()); 127 } 128 } 129 } 130 | Popular Tags |