KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > taglibs > MainBar


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2005 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

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 JavaDoc;
19
20 import javax.servlet.http.HttpServletRequest JavaDoc;
21 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
22
23 import org.apache.commons.lang.StringUtils;
24 import org.apache.log4j.Logger;
25
26
27 /**
28  * @author Marcel Salathe
29  * @author Sameer Charles
30  * @version $Revision: 1209 $ ($Author: fgiust $)
31  */

32 public class MainBar extends TagSupport JavaDoc {
33
34     /**
35      * Stable serialVersionUID.
36      */

37     private static final long serialVersionUID = 222L;
38
39     /**
40      * Logger.
41      */

42     private static Logger log = Logger.getLogger(MainBar.class);
43
44     private String JavaDoc paragraph;
45
46     private boolean adminButtonVisible;
47
48     /**
49      * @see javax.servlet.jsp.tagext.Tag#doStartTag()
50      */

51     public int doStartTag() {
52         return EVAL_BODY_INCLUDE;
53     }
54
55     /**
56      * @see javax.servlet.jsp.tagext.Tag#doEndTag()
57      */

58     public int doEndTag() {
59         /*
60          * if (!ServerInfo.isAdmin()) return EVAL_PAGE; if
61          * (!Resource.getActivePage(this.request).isGranted(Permission.WRITE_PROPERTY)) return EVAL_PAGE;
62          */

63         try {
64             this.display();
65         }
66         catch (Exception JavaDoc e) {
67             log.warn("Exception caught during display: " + e.getMessage(), e); //$NON-NLS-1$
68
}
69         return EVAL_PAGE;
70     }
71
72     /**
73      * <p>
74      * get the content path (Page or Node)
75      * </p>
76      * @return String path
77      */

78     private String JavaDoc getPath() {
79         HttpServletRequest JavaDoc request = (HttpServletRequest JavaDoc) this.pageContext.getRequest();
80         try {
81             return Resource.getCurrentActivePage(request).getHandle();
82         }
83         catch (Exception JavaDoc re) {
84             return StringUtils.EMPTY;
85         }
86     }
87
88     /**
89      * <p>
90      * set current content type, could be any developer defined name
91      * </p>
92      * /**
93      * @deprecated
94      * @param type , paragraph type
95      */

96     public void setParFile(String JavaDoc type) {
97         this.setParagraph(type);
98     }
99
100     /**
101      * <p>
102      * set paragarph type
103      * </p>
104      * /**
105      * @param s , pargarph type
106      */

107     public void setParagraph(String JavaDoc s) {
108         this.paragraph = s;
109     }
110
111     /**
112      * @return pargraph type
113      */

114     private String JavaDoc getParagraph() {
115         return this.paragraph;
116     }
117
118     /**
119      * <p>
120      * displays main admin bar
121      * </p>
122      * @throws java.io.IOException
123      */

124     private void display() throws IOException JavaDoc {
125         HttpServletRequest JavaDoc request = (HttpServletRequest JavaDoc) 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     /**
143      * @see javax.servlet.jsp.tagext.TagSupport#release()
144      */

145     public void release() {
146         super.release();
147         this.paragraph = null;
148         this.adminButtonVisible = false;
149     }
150 }
151
Popular Tags