001: /*
002: * Version: MPL 1.1/GPL 2.0/LGPL 2.1
003: *
004: * "The contents of this file are subject to the Mozilla Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License at
007: * http://www.mozilla.org/MPL/
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
011: * License for the specific language governing rights and limitations under
012: * the License.
013: *
014: * The Original Code is ICEfaces 1.5 open source software code, released
015: * November 5, 2006. The Initial Developer of the Original Code is ICEsoft
016: * Technologies Canada, Corp. Portions created by ICEsoft are Copyright (C)
017: * 2004-2006 ICEsoft Technologies Canada, Corp. All Rights Reserved.
018: *
019: * Contributor(s): _____________________.
020: *
021: * Alternatively, the contents of this file may be used under the terms of
022: * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"
023: * License), in which case the provisions of the LGPL License are
024: * applicable instead of those above. If you wish to allow use of your
025: * version of this file only under the terms of the LGPL License and not to
026: * allow others to use your version of this file under the MPL, indicate
027: * your decision by deleting the provisions above and replace them with
028: * the notice and other provisions required by the LGPL License. If you do
029: * not delete the provisions above, a recipient may use your version of
030: * this file under either the MPL or the LGPL License."
031: *
032: */
033:
034: package com.icesoft.faces.component.menubar;
035:
036: import javax.swing.tree.DefaultMutableTreeNode;
037:
038: public class IceMenuObject {
039:
040: protected DefaultMutableTreeNode wrapper;
041: protected String text;
042: protected boolean expanded;
043: protected String tooltip;
044: protected String action;
045:
046: // icon fields
047: protected String leafIcon;
048: protected String branchExpandedIcon;
049: protected String branchContractedIcon;
050: protected String icon;
051:
052: //constructors
053: public IceMenuObject(DefaultMutableTreeNode wrapper) {
054: this .wrapper = wrapper;
055: }
056:
057: public String action() {
058: return action;
059: }
060:
061: // getters/setters
062: public String getText() {
063: return text;
064: }
065:
066: public void setText(String text) {
067: this .text = text;
068: }
069:
070: public String getFamily() {
071: return null;
072: }
073:
074: public boolean isExpanded() {
075: return expanded;
076: }
077:
078: public void setExpanded(boolean isExpanded) {
079: this .expanded = isExpanded;
080: }
081:
082: public String getTooltip() {
083: return tooltip;
084: }
085:
086: public void setTooltip(String tooltipString) {
087: this .tooltip = tooltipString;
088: }
089:
090: public String toString() {
091: return text;
092: }
093:
094: public String getLeafIcon() {
095: return leafIcon;
096: }
097:
098: public void setLeafIcon(String leafIcon) {
099: this .leafIcon = leafIcon;
100: }
101:
102: public String getBranchContractedIcon() {
103: return branchContractedIcon;
104: }
105:
106: public void setBranchContractedIcon(String branchContractedIcon) {
107: this .branchContractedIcon = branchContractedIcon;
108: }
109:
110: public String getBranchExpandedIcon() {
111: return branchExpandedIcon;
112: }
113:
114: public void setBranchExpandedIcon(String branchExpandedIcon) {
115: this .branchExpandedIcon = branchExpandedIcon;
116: }
117:
118: /**
119: * return the appropriate icon based on this node's expanded/collapsed state
120: * and the presence of children
121: *
122: * @return String application-relative path to the image file
123: */
124: public String getIcon() {
125: if (wrapper.getChildCount() <= 0) {
126: if (leafIcon != null) {
127: return leafIcon;
128: }
129: } else if (isExpanded()) {
130: if (branchExpandedIcon != null) {
131: return branchExpandedIcon;
132: }
133: } else {
134: if (branchContractedIcon != null) {
135: return branchContractedIcon;
136: }
137: }
138: return icon;
139: }
140:
141: public DefaultMutableTreeNode getWrapper() {
142: return wrapper;
143: }
144:
145: /**
146: * Set the DefaultMutableTreeNode instance that wraps this instance
147: *
148: * @param wrapper
149: */
150: public void setWrapper(DefaultMutableTreeNode wrapper) {
151: this .wrapper = wrapper;
152: }
153:
154: public String getAction() {
155: return action;
156: }
157:
158: public void setAction(String action) {
159: this.action = action;
160: }
161: }
|