KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.Iterator JavaDoc;
16
17
18 /**
19  * Represents an item in the function bar.
20  * @author higi
21  */

22 public class FunctionBarItem extends ContextMenuItem {
23
24     private boolean active = false;
25
26     public FunctionBarItem(String JavaDoc name) {
27         super(name);
28         this.active = false;
29     }
30
31     /**
32      * Copy constructor. Used because the most buttons are redundant to it's context menu item
33      * @param item
34      */

35     public FunctionBarItem(ContextMenuItem item) {
36         this.setName(item.getName());
37         this.setLabel(item.getLabel());
38         if (item.getIcon() != null) {
39             this.setIcon(item.getIcon().replaceFirst("/16/", "/24/"));
40         }
41         this.setJavascriptMenuName(item.getJavascriptMenuName());
42         this.setOnclick(item.getOnclick());
43         java.util.List JavaDoc jsConds = item.getJavascriptConditions();
44         for (Iterator JavaDoc iter = jsConds.iterator(); iter.hasNext();) {
45             String JavaDoc condition = (String JavaDoc) iter.next();
46             this.addJavascriptCondition(condition);
47             // I.E. : new mgnlTreeMenuItemConditionSelectedNotRoot(mgnlTreeControl)
48
}
49         this.active = false;
50     }
51
52     /**
53      * @return Returns the active.
54      */

55     public boolean isActive() {
56         return active;
57     }
58
59     /**
60      * @param active The active to set.
61      */

62     public void setActive(boolean active) {
63         this.active = active;
64     }
65
66     /**
67      * Add the _inactive suffix.
68      * @return the proper name
69      */

70     public String JavaDoc getInactiveIcon() {
71         if (super.getIcon() != null) {
72             return super.getIcon().replaceFirst(".gif", "_inactive.gif");
73         }
74         return null;
75     }
76 }
77
Popular Tags