001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/velocity/tags/sakai_2-4-1/tool/src/java/org/sakaiproject/cheftool/menu/MenuField.java $
003: * $Id: MenuField.java 7247 2006-03-29 21:09:51Z ggolden@umich.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.cheftool.menu;
021:
022: import java.util.List;
023: import java.util.Vector;
024:
025: import org.sakaiproject.cheftool.api.MenuItem;
026:
027: /**
028: * <p>
029: * MenuField is a text entry field in a menu / toolbar.
030: * </p>
031: */
032: public class MenuField implements MenuItem {
033: /** The form field name. */
034: protected String m_name = null;
035:
036: /** The form name string for the entry. */
037: protected String m_form = null;
038:
039: /** The value to display in the field. */
040: protected String m_value = null;
041:
042: /** The action to perform. */
043: protected String m_action = null;
044:
045: /**
046: * Construct.
047: */
048: public MenuField(String name, String form, String action,
049: String value) {
050: m_name = name;
051: m_form = form;
052: m_action = action;
053: m_value = value;
054:
055: } // MenuField
056:
057: /**
058: * Set the full URL of the entry. To create an entry with a URL, create one first with a "" action, then call this.
059: *
060: * @param url
061: * The full URL for the entry.
062: * @return This, for convenience.
063: */
064: public MenuField setUrl(String url) {
065: return this ;
066: }
067:
068: /**
069: * Does this item act as a container for other items?
070: *
071: * @return true if this MenuItem is a container for other items, false if not.
072: */
073: public boolean getIsContainer() {
074: return false;
075:
076: } // getIsContainer
077:
078: /**
079: * Is this item a divider ?
080: *
081: * @return true if this MenuItem is a divider, false if not.
082: */
083: public boolean getIsDivider() {
084: return false;
085:
086: } // getIsDivider
087:
088: /**
089: * Access the display title for the item - this is really the form field name.
090: *
091: * @return The display title for the item - but really, the form field name.
092: */
093: public String getTitle() {
094: return ((m_name == null) ? "" : m_name);
095:
096: } // getTitle
097:
098: /**
099: * Access the icon name for the item (or null if no icon).
100: *
101: * @return The icon name for the item (or null if no icon).
102: */
103: public String getIcon() {
104: return null;
105: }
106:
107: /**
108: * Access the enabled flag for the item.
109: *
110: * @return True if the item is enabled, false if not.
111: */
112: public boolean getIsEnabled() {
113: return true;
114: }
115:
116: /**
117: * Access the value string for this item - the initial value.
118: *
119: * @return The value string for this item - the initial value.
120: */
121: public String getValue() {
122: return ((m_value == null) ? "" : m_value);
123:
124: } // getValue
125:
126: /**
127: * Access the action string for this item; what to do when the user clicks. Note: if getIsMenu(), there will not be an action string (will return ""). Note: if the entry is not enabled, this will return "".
128: *
129: * @return The action string for this item.
130: */
131: public String getAction() {
132: return ((m_action == null) ? "" : m_action);
133:
134: } // getAction
135:
136: /**
137: * Access the full URL string for this item; what to do when the user clicks. Note: this if defined overrides getAction() which should be "". Note: if getIsMenu(), there will not be a URL string (will return "").
138: *
139: * @return The full URL string for this item.
140: */
141: public String getUrl() {
142: return "";
143: }
144:
145: /**
146: * Access the form name whose values will be used when this item is selected.
147: *
148: * @return The form name whose values will be used when this item is selected.
149: */
150: public String getForm() {
151: return m_form;
152:
153: } // getForm
154:
155: /**
156: * Access the sub-items of the item. Note: if !isContainer(), there will be no sub-items (will return EmptyIterator).
157: *
158: * @return The sub-items of the item.
159: */
160: public List getItems() {
161: return new Vector();
162:
163: } // getItems
164:
165: /**
166: * Access one sub-items of the item. Note: if !isContainer(), there will be no sub-items (will return null).
167: *
168: * @param index
169: * The index position (0 based) for the sub-item to get.
170: * @return The sub-item of the item.
171: */
172: public MenuItem getItem(int index) {
173: return null;
174:
175: } // getItem
176:
177: /**
178: * Access the checked status of this item. Possible values:
179: *
180: * @see MenuItem
181: * @return The the checked status of this item.
182: */
183: public int getChecked() {
184: return CHECKED_NA;
185:
186: } // getChecked
187:
188: /**
189: * Count the sub-items of the item. Note: if !isContainer(), the count is 0.
190: *
191: * @return The count of sub-items of the item.
192: */
193: public int size() {
194: return 0;
195:
196: } // size
197:
198: /**
199: * Check if there are any sub-items. Note: if !isContainer(), this is empty.
200: *
201: * @return true of there are no sub-items, false if there are.
202: */
203: public boolean isEmpty() {
204: return true;
205:
206: } // isEmpty
207:
208: /**
209: * Access the is-field (not a button) flag.
210: *
211: * @return True if the item is a field, false if not.
212: */
213: public boolean getIsField() {
214: return true;
215:
216: } // getIsField
217:
218: } // MenuField
|