001: package org.gridsphere.provider.portletui.beans;
002:
003: import org.gridsphere.portlet.service.spi.PortletServiceFactory;
004: import org.gridsphere.services.core.portal.PortalConfigService;
005:
006: public class DialogBean extends BaseComponentBean {
007:
008: protected String header = "";
009: protected String body = "";
010: protected String footer = "";
011: protected String width = "";
012: protected String height = "";
013: protected String titleColor = null;
014: protected Boolean isModal = false;
015: protected Boolean isClose = true;
016: protected Boolean isDraggable = true;
017: protected Boolean isResizable = false;
018: protected Boolean isLink = false;
019: protected String onClick = "";
020:
021: /**
022: * Constructs a default table row bean
023: */
024: public DialogBean() {
025: super ();
026: }
027:
028: public Boolean getClose() {
029: return isClose;
030: }
031:
032: public void setClose(Boolean close) {
033: isClose = close;
034: }
035:
036: public Boolean getModal() {
037: return isModal;
038: }
039:
040: public void setModal(Boolean modal) {
041: isModal = modal;
042: }
043:
044: public Boolean getResizable() {
045: return isResizable;
046: }
047:
048: public void setResizable(Boolean resizable) {
049: isResizable = resizable;
050: }
051:
052: public Boolean getDraggable() {
053: return isDraggable;
054: }
055:
056: public void setDraggable(Boolean draggable) {
057: isDraggable = draggable;
058: }
059:
060: public String getOnClick() {
061: return onClick;
062: }
063:
064: public void setOnClick(String onClick) {
065: this .onClick = onClick;
066: }
067:
068: public Boolean getLink() {
069: return isLink;
070: }
071:
072: public void setLink(Boolean link) {
073: isLink = link;
074: }
075:
076: public String getTitleColor() {
077: return titleColor;
078: }
079:
080: public void setTitleColor(String titleColor) {
081: this .titleColor = titleColor;
082: }
083:
084: public String getHeader() {
085: return header;
086: }
087:
088: public void setHeader(String header) {
089: this .header = header;
090: }
091:
092: public String getBody() {
093: return body;
094: }
095:
096: public void setBody(String body) {
097: this .body = body;
098: }
099:
100: public String getFooter() {
101: return footer;
102: }
103:
104: public void setFooter(String footer) {
105: this .footer = footer;
106: }
107:
108: public String getWidth() {
109: return width;
110: }
111:
112: public void setWidth(String width) {
113: this .width = width;
114: }
115:
116: public String getHeight() {
117: return height;
118: }
119:
120: public void setHeight(String height) {
121: this .height = height;
122: }
123:
124: public String toStartString() {
125: StringBuffer sb = new StringBuffer();
126: if (key != null)
127: value = getLocalizedText(key);
128: value = value.replaceAll("\n", "<br>");
129: PortalConfigService configService = (PortalConfigService) PortletServiceFactory
130: .createPortletService(PortalConfigService.class, true);
131: // deal with ROOT context case
132: String contextPath = configService
133: .getProperty("gridsphere.deploy");
134: if (!contextPath.equals(""))
135: contextPath = "/" + contextPath;
136: //renderResponse.addProperty("CSS_HREF", contextPath + "/css/yahoo/reset.css");
137: //renderResponse.addProperty("CSS_HREF", contextPath + "/css/yahoo/fonts.css");
138: renderResponse.addProperty("CSS_HREF", contextPath
139: + "/css/yahoo/container.css");
140: if (isResizable)
141: renderResponse.addProperty("CSS_HREF", contextPath
142: + "/css/yahoo/ResizePanel.css");
143:
144: renderResponse.addProperty("JAVASCRIPT_SRC", contextPath
145: + "/javascript/yahoo/event.js");
146: renderResponse.addProperty("JAVASCRIPT_SRC", contextPath
147: + "/javascript/yahoo/dom.js");
148: renderResponse.addProperty("JAVASCRIPT_SRC", contextPath
149: + "/javascript/yahoo/fonts.js");
150: renderResponse.addProperty("JAVASCRIPT_SRC", contextPath
151: + "/javascript/yahoo/container.js");
152: renderResponse.addProperty("JAVASCRIPT_SRC", contextPath
153: + "/javascript/yahoo/animation.js");
154: renderResponse.addProperty("JAVASCRIPT_SRC", contextPath
155: + "/javascript/yahoo/dragdrop.js");
156: if (isResizable)
157: renderResponse.addProperty("JAVASCRIPT_SRC", contextPath
158: + "/javascript/yahoo/ResizePanel.js");
159: sb.append("<script type=\"text/javascript\">\n");
160: sb.append("YAHOO.namespace(\"").append(id).append("\");\n");
161: sb.append("function init() {\n");
162: if (!width.endsWith("px"))
163: width += "px";
164: if (!height.endsWith("px"))
165: height += "px";
166: String resizable = "";
167: if (isResizable.booleanValue())
168: resizable = "Resize";
169: sb
170: .append("YAHOO.")
171: .append(id)
172: .append(".panel = new YAHOO.widget.")
173: .append(resizable)
174: .append("Panel(\"")
175: .append(name)
176: .append("\", { width:\"")
177: .append(width)
178: .append("\", height:\"")
179: .append(height)
180: .append(
181: "\", fixedcenter: true, constraintoviewport: true, iframe: true, underlay:\"shadow\", close:")
182: .append(isClose).append(", modal:").append(isModal)
183: .append(", visible:false, draggable:").append(
184: isDraggable).append("} );\n");
185: sb.append("YAHOO.").append(id).append(
186: ".panel.render( document.body );\n");
187: // sb.append("YAHOO." + name + ".panel.setHeader(\"" + header + "\");\n");
188: // sb.append("YAHOO." + name + ".panel.setBody(\"" + body + "\");\n");
189: // sb.append("YAHOO." + name + ".panel.setFooter(\"" + footer + "\");\n");
190: sb.append("}\n");
191: sb
192: .append("YAHOO.util.Event.addListener(window, \"load\", init);");
193: sb.append("</script>");
194: if (isLink) {
195: sb.append("<a href=\"#\" ");
196: if (onClick != null)
197: sb.append("onclick=\"").append(onClick);
198: sb.append("\">").append(value).append("</a>\n");
199: } else {
200: sb.append("<button type=\"button\" onclick=\"").append(
201: onClick).append("\">").append(value).append(
202: "</button>\n");
203: }
204: sb.append("<div id=\"").append(id).append("\">");
205: sb.append("<div ");
206: if (titleColor != null)
207: sb.append("style=\"background-color: ").append(titleColor)
208: .append(";\" ");
209: sb.append("class=\"hd\">").append(header).append("</div>");
210: sb.append("<div class=\"bd\">").append(body).append("</div>");
211: sb.append("<div class=\"ft\">").append(footer).append(
212: "</div></div>");
213: return sb.toString();
214: }
215:
216: public String toEndString() {
217: return "";
218: }
219:
220: }
|