KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > gui > control > FunctionBar


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-2006 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.cms.gui.control;
14
15 import info.magnolia.cms.util.FreeMarkerUtil;
16
17 import java.util.HashMap JavaDoc;
18 import java.util.Map JavaDoc;
19
20
21 /**
22  * The bar containing function buttons and the search field.
23  * @author higi
24  */

25 public class FunctionBar extends ContextMenu {
26
27     /**
28      * Name to reference this object in js
29      */

30     private String JavaDoc javascriptName;
31
32     /**
33      * True if the search field is showed
34      */

35     private boolean searchable = false;
36
37     /**
38      * Javascript called if Enter is pressed in the field
39      */

40     private String JavaDoc onSearchFunction = "function(val){alert(val)}";
41
42     /**
43      * String already present in the search field
44      */

45     private String JavaDoc searchStr = "";
46
47     /**
48      * @param menuName the name of this menu (used in js)
49      */

50     public FunctionBar(String JavaDoc menuName) {
51         super(menuName);
52         this.javascriptName = "mgnlFunctionBar";
53     }
54
55     /**
56      * Render the html code using the freemarker template
57      */

58     public String JavaDoc getHtml() {
59         Map JavaDoc params = new HashMap JavaDoc();
60         params.put("functionBar", this);
61         return FreeMarkerUtil.process("info/magnolia/cms/gui/control/FunctionBar.ftl", params);
62     }
63
64     /**
65      * Render the javascript code to initialize it
66      */

67     public String JavaDoc getJavascript() {
68         Map JavaDoc params = new HashMap JavaDoc();
69         params.put("functionBar", this);
70         return FreeMarkerUtil.process("info/magnolia/cms/gui/control/FunctionBarJavascript.ftl", params);
71     }
72
73     /**
74      * @return true if the functionBar has one or more functionBarItems
75      */

76     public boolean hasMenuItems() {
77         return !this.getMenuItems().isEmpty();
78     }
79
80     /**
81      * @return Returns the javascriptName.
82      */

83     public String JavaDoc getJavascriptName() {
84         return javascriptName;
85     }
86
87     /**
88      * @param javascriptName The javascriptName to set.
89      */

90     public void setJavascriptName(String JavaDoc javascriptName) {
91         this.javascriptName = javascriptName;
92     }
93
94     /**
95      * @return Returns the searchable.
96      */

97     public boolean isSearchable() {
98         return this.searchable;
99     }
100
101     /**
102      * @param searchable The searchable to set.
103      */

104     public void setSearchable(boolean searchable) {
105         this.searchable = searchable;
106     }
107
108     /**
109      * @return Returns the onSearchFunction.
110      */

111     public String JavaDoc getOnSearchFunction() {
112         return this.onSearchFunction;
113     }
114
115     /**
116      * @param onSearchFunction The onSearchFunction to set.
117      */

118     public void setOnSearchFunction(String JavaDoc onSearch) {
119         this.onSearchFunction = onSearch;
120     }
121
122     /**
123      * @return Returns the searchStr.
124      */

125     public String JavaDoc getSearchStr() {
126         return this.searchStr;
127     }
128
129     /**
130      * @param searchStr The searchStr to set.
131      */

132     public void setSearchStr(String JavaDoc searchStr) {
133         this.searchStr = searchStr;
134     }
135 }
136
Popular Tags