001: package org.gridsphere.provider.portletui.beans;
002:
003: import java.util.Iterator;
004:
005: /*
006: * @author <a href="mailto:oliver.wehrens@aei.mpg.de">Oliver Wehrens</a>
007: * @version $Id: ActionMenuItemBean.java 6385 2007-10-25 14:02:26Z wehrens $
008: */
009:
010: public class ActionMenuItemBean extends BeanContainer {
011:
012: protected boolean seperator = false;
013: protected String align = ActionMenuBean.MENU_HORIZONTAL;
014: protected String menutype = ActionMenuBean.TYPE_ACTIONBAR;
015: protected boolean isSelected = false;
016:
017: //protected String info = null;
018:
019: public ActionMenuItemBean() {
020: super ();
021: }
022:
023: public ActionMenuItemBean(String beanId) {
024: super ();
025: this .beanId = beanId;
026: }
027:
028: public String getMenutype() {
029: return menutype;
030: }
031:
032: public void setMenutype(String menutype) {
033: this .menutype = menutype;
034: }
035:
036: public String getAlign() {
037: return align;
038: }
039:
040: /**
041: * Sets the alignment of the MenuItem. If it is added to a @see ActionMenuBean the alignment from that one
042: * has will be used.
043: *
044: * @param menualign
045: */
046: public void setAlign(String menualign) {
047: this .align = menualign;
048: }
049:
050: public boolean isSeperator() {
051: return seperator;
052: }
053:
054: public void setSeperator(boolean seperator) {
055: this .seperator = seperator;
056: }
057:
058: public boolean isSelected() {
059: return isSelected;
060: }
061:
062: public void setSelected(boolean selected) {
063: isSelected = selected;
064: }
065:
066: public String toStartString() {
067: StringBuffer sb = new StringBuffer();
068: if (menutype.equals(ActionMenuBean.TYPE_ACTIONTAB)) {
069: if (isSelected()) {
070: sb.append("<div id=\"actiontabselected\">");
071: }
072: sb.append("<li id=\"actiontabmenu\">");
073: } else if (menutype.equals(ActionMenuBean.TYPE_ACTIONBAR)) {
074: if (this .align.equals(ActionMenuBean.MENU_VERTICAL)) {
075: sb
076: .append("<div style=\"display: block; margin-top: 5px;\">");
077: }
078: }
079:
080: return sb.toString();
081: }
082:
083: public String toEndString() {
084: StringBuffer sb = new StringBuffer();
085:
086: Iterator it = container.iterator();
087: while (it.hasNext()) {
088: BaseComponentBean itemBean = (BaseComponentBean) it.next();
089: sb.append(itemBean.toStartString());
090: sb.append(itemBean.toEndString());
091: }
092:
093: if (menutype.equals(ActionMenuBean.TYPE_ACTIONTAB)) {
094: sb.append("</li>");
095: if (isSelected()) {
096: sb.append("</div>");
097: }
098: } else if (menutype.equals(ActionMenuBean.TYPE_ACTIONBAR)) {
099: if (align.equals(ActionMenuBean.MENU_VERTICAL)) {
100: sb.append("</div>");
101: }
102: }
103:
104: return sb.toString();
105: }
106: }
|