KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > deprecated > taglibs > button > ContainerListPropertiesButtonTag


1 package org.jahia.deprecated.taglibs.button;
2
3 import java.util.Enumeration JavaDoc;
4
5 import javax.servlet.jsp.JspException JavaDoc;
6
7 import org.jahia.data.JahiaData;
8 import org.jahia.data.containers.JahiaContainerList;
9 import org.jahia.deprecated.taglibs.container.ContainerListTag;
10 import org.jahia.exceptions.JahiaException;
11 import org.jahia.services.usermanager.JahiaUser;
12
13
14 /**
15  * Class ContainerListPropertiesButtonTag :
16  * returns the full link ("<a href...>...</a>") allowing to
17  * open the container list properties popup window if the user is authorized
18  *
19  * @author Jerome Tamiotti
20  */

21 public class ContainerListPropertiesButtonTag extends AbstractButtonTag {
22
23     private JahiaContainerList containerList = null;
24     private String JavaDoc title = "Properties";
25     private String JavaDoc style = "";
26
27     public void setTitle(String JavaDoc title) {
28         this.title = title;
29     }
30
31     public void setStyle(String JavaDoc style) {
32         this.style = style;
33     }
34
35     public String JavaDoc getTitle() {
36         return this.title;
37     }
38
39     public String JavaDoc getStyle() {
40         return this.style;
41     }
42
43     public boolean testRights (JahiaData jData) {
44         JahiaUser user = jData.params().getUser();
45         // retrieves the current container list
46
ContainerListTag parent = (ContainerListTag) findAncestorWithClass(this,ContainerListTag.class);
47         if (parent != null) {
48             if (parent.isDeclarationPass()) {
49                 return false;
50             }
51             containerList = parent.getContainerList();
52         }
53         if (containerList != null) {
54             Enumeration JavaDoc containers = containerList.getContainers();
55             return ( containers.hasMoreElements() &&
56                      containerList.checkWriteAccess(user) &&
57                      jData.gui().isEditMode() );
58         }
59         return false;
60     }
61
62     public String JavaDoc getLauncher(JahiaData jData) throws JahiaException {
63         // returns the URL that launches the container list properties popup window
64
return "javascript:" + jData.gui().html().drawContainerListPropertiesLauncher(this.containerList);
65     }
66
67     public int doEndTag() throws JspException JavaDoc {
68         // let's reinitialize the tag variables to allow tag object reuse in
69
// pooling.
70
containerList = null;
71         title = "Properties";
72         style = "";
73         return EVAL_PAGE;
74     }
75
76
77 }
78
Popular Tags