KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > module > admininterface > dialogpages > LinkBrowserDialogPage


1 package info.magnolia.module.admininterface.dialogpages;
2
3 import info.magnolia.cms.beans.config.ContentRepository;
4 import info.magnolia.cms.gui.control.Button;
5 import info.magnolia.cms.gui.misc.CssConstants;
6 import info.magnolia.cms.gui.misc.Sources;
7 import info.magnolia.cms.i18n.MessagesManager;
8 import info.magnolia.module.admininterface.DialogPageMVCHandler;
9
10 import java.io.IOException JavaDoc;
11 import java.io.PrintWriter JavaDoc;
12 import java.util.Date JavaDoc;
13
14 import javax.servlet.http.HttpServletRequest JavaDoc;
15 import javax.servlet.http.HttpServletResponse JavaDoc;
16
17 import org.apache.commons.lang.StringUtils;
18
19
20 /**
21  * @author Fabrizio Giustina
22  * @version $Id: $
23  */

24 public class LinkBrowserDialogPage extends DialogPageMVCHandler {
25
26     public LinkBrowserDialogPage(String JavaDoc name, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) {
27         super(name, request, response);
28     }
29
30     /**
31      * Stable serialVersionUID.
32      */

33     private static final long serialVersionUID = 222L;
34
35     protected void draw(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws IOException JavaDoc {
36         PrintWriter JavaDoc out = response.getWriter();
37         String JavaDoc repository = request.getParameter("repository"); //$NON-NLS-1$
38
if (StringUtils.isEmpty(repository)) {
39             repository = ContentRepository.WEBSITE;
40         }
41
42         String JavaDoc path = request.getParameter("path"); //$NON-NLS-1$
43
String JavaDoc pathOpen = request.getParameter("pathOpen"); //$NON-NLS-1$
44
String JavaDoc pathSelected = request.getParameter("pathSelected"); //$NON-NLS-1$
45

46         StringBuffer JavaDoc html = new StringBuffer JavaDoc();
47         html.append("<html><head>"); //$NON-NLS-1$
48
html.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>"); //$NON-NLS-1$
49
html.append(new Sources(request.getContextPath()).getHtmlJs());
50         html.append(new Sources(request.getContextPath()).getHtmlCss());
51         html.append("</head>"); //$NON-NLS-1$
52
html.append("<body class=\"mgnlBgDark\" onload=\"mgnlDialogLinkBrowserResize();\">"); //$NON-NLS-1$
53

54         StringBuffer JavaDoc src = getIFrameSrc(request, repository, path, pathOpen, pathSelected);
55         
56         html.append("<div id=\"mgnlTreeDiv\" class=\"mgnlDialogLinkBrowserTreeDiv\">"); //$NON-NLS-1$
57
html.append("<iframe id=\"mgnlDialogLinkBrowserIFrame\" name=\"mgnlDialogLinkBrowserIFrame\" SRC=\"" //$NON-NLS-1$
58
+ src + "\" scrolling=\"no\" frameborder=\"0\" width=\"100%\" height=\"100\"></iframe>"); //$NON-NLS-1$
59
html.append("</div>"); //$NON-NLS-1$
60

61         Button bOk = new Button();
62         bOk.setLabel(MessagesManager.get(request, "buttons.ok")); //$NON-NLS-1$
63
// this will call the callback command
64
bOk.setOnclick("mgnlDialogLinkBrowserWriteBack()"); //$NON-NLS-1$
65

66         Button bCancel = new Button();
67         bCancel.setLabel(MessagesManager.get(request, "buttons.cancel")); //$NON-NLS-1$
68
bCancel.setOnclick("window.close();"); //$NON-NLS-1$
69

70         html.append("<div class=\"" + CssConstants.CSSCLASS_TABSETSAVEBAR + "\">"); //$NON-NLS-1$ //$NON-NLS-2$
71
html.append(bOk.getHtml());
72         html.append(" "); //$NON-NLS-1$
73
html.append(bCancel.getHtml());
74         html.append("</div>"); //$NON-NLS-1$
75

76         html.append("</body></html>"); //$NON-NLS-1$
77

78         out.println(html);
79     }
80
81     private StringBuffer JavaDoc getIFrameSrc(HttpServletRequest JavaDoc request, String JavaDoc repository, String JavaDoc path, String JavaDoc pathOpen, String JavaDoc pathSelected) {
82         StringBuffer JavaDoc src = new StringBuffer JavaDoc();
83         src.append(request.getContextPath());
84         src.append("/.magnolia/adminCentral/extractTree.html"); //$NON-NLS-1$
85
src.append("?&amp;mgnlCK=" + new Date JavaDoc().getTime()); //$NON-NLS-1$
86
src.append("&amp;name=" + repository); //$NON-NLS-1$
87
src.append("&amp;browseMode=true"); //$NON-NLS-1$
88
if (path != null) {
89             src.append("&amp;path=" + path); //$NON-NLS-1$
90
}
91         if (pathOpen != null) {
92             src.append("&amp;pathOpen=" + pathOpen); //$NON-NLS-1$
93
}
94         if (pathSelected != null) {
95             src.append("&amp;pathSelected=" + pathSelected); //$NON-NLS-1$
96
}
97         return src;
98     }
99 }
100
Popular Tags