001: /*******************************************************************************
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: *******************************************************************************/package org.ofbiz.widget.menu;
019:
020: import java.util.HashMap;
021: import java.util.Iterator;
022: import java.util.LinkedList;
023: import java.util.List;
024: import java.util.Map;
025:
026: import org.ofbiz.base.util.BshUtil;
027: import org.ofbiz.base.util.Debug;
028: import org.ofbiz.base.util.UtilValidate;
029: import org.ofbiz.base.util.UtilXml;
030: import org.ofbiz.base.util.string.FlexibleStringExpander;
031: import org.ofbiz.base.util.collections.FlexibleMapAccessor;
032: import org.ofbiz.entity.GenericDelegator;
033: import org.ofbiz.service.LocalDispatcher;
034: import org.w3c.dom.Element;
035:
036: import bsh.EvalError;
037: import bsh.Interpreter;
038:
039: /**
040: * Widget Library - Menu model class
041: */
042: public class ModelMenu {
043:
044: public static final String module = ModelMenu.class.getName();
045:
046: protected GenericDelegator delegator;
047: protected LocalDispatcher dispatcher;
048:
049: protected String name;
050: protected String type;
051: protected String target;
052: protected String id;
053: protected FlexibleStringExpander title;
054: protected String tooltip;
055: protected String defaultEntityName;
056: protected String defaultTitleStyle;
057: protected String defaultWidgetStyle;
058: protected String defaultTooltipStyle;
059: protected String defaultSelectedStyle;
060: protected String defaultMenuItemName;
061: protected String currentMenuItemName;
062: protected String defaultPermissionOperation;
063: protected String defaultPermissionEntityAction;
064: protected FlexibleStringExpander defaultAssociatedContentId;
065: protected String defaultPermissionStatusId;
066: protected String defaultPrivilegeEnumId;
067: protected String orientation = "horizontal";
068: protected String menuWidth;
069: protected String defaultCellWidth;
070: protected Boolean defaultHideIfSelected;
071: protected String defaultDisabledTitleStyle;
072: protected FlexibleMapAccessor selectedMenuItemContextFieldName;
073: protected FlexibleStringExpander menuContainerStyleExdr;
074: protected String defaultAlign;
075: protected String defaultAlignStyle;
076: protected String fillStyle;
077:
078: /** This List will contain one copy of each item for each item name in the order
079: * they were encountered in the service, entity, or menu definition; item definitions
080: * with constraints will also be in this list but may appear multiple times for the same
081: * item name.
082: *
083: * When rendering the menu the order in this list should be following and it should not be
084: * necessary to use the Map. The Map is used when loading the menu definition to keep the
085: * list clean and implement the override features for item definitions.
086: */
087: protected List menuItemList = new LinkedList();
088:
089: /** This Map is keyed with the item name and has a ModelMenuItem for the value; items
090: * with conditions will not be put in this Map so item definition overrides for items
091: * with conditions is not possible.
092: */
093: protected Map menuItemMap = new HashMap();
094:
095: protected List actions;
096:
097: // ===== CONSTRUCTORS =====
098: /** Default Constructor */
099: public ModelMenu() {
100: }
101:
102: /** XML Constructor */
103: public ModelMenu(Element menuElement, GenericDelegator delegator,
104: LocalDispatcher dispatcher) {
105: this .delegator = delegator;
106: this .dispatcher = dispatcher;
107:
108: // check if there is a parent menu to inherit from
109: String parentResource = menuElement
110: .getAttribute("extends-resource");
111: String parentMenu = menuElement.getAttribute("extends");
112: if (parentMenu.length() > 0
113: && !(parentMenu
114: .equals(menuElement.getAttribute("name")) && UtilValidate
115: .isEmpty(parentResource))) {
116: ModelMenu parent = null;
117: // check if we have a resource name (part of the string before the ?)
118: if (UtilValidate.isNotEmpty(parentResource)) {
119: try {
120: parent = MenuFactory.getMenuFromLocation(
121: parentResource, parentMenu, delegator,
122: dispatcher);
123: } catch (Exception e) {
124: Debug.logError(e,
125: "Failed to load parent menu definition '"
126: + parentMenu + "' at resource '"
127: + parentResource + "'", module);
128: }
129: } else {
130: // try to find a menu definition in the same file
131: Element rootElement = menuElement.getOwnerDocument()
132: .getDocumentElement();
133: List menuElements = UtilXml.childElementList(
134: rootElement, "menu");
135: //Uncomment below to add support for abstract menus
136: //menuElements.addAll(UtilXml.childElementList(rootElement, "abstract-menu"));
137: Iterator menuElementIter = menuElements.iterator();
138: while (menuElementIter.hasNext()) {
139: Element menuElementEntry = (Element) menuElementIter
140: .next();
141: if (menuElementEntry.getAttribute("name").equals(
142: parentMenu)) {
143: parent = new ModelMenu(menuElementEntry,
144: delegator, dispatcher);
145: break;
146: }
147: }
148: if (parent == null) {
149: Debug.logError(
150: "Failed to find parent menu defenition '"
151: + parentMenu
152: + "' in same document.", module);
153: }
154: }
155:
156: if (parent != null) {
157: this .type = parent.type;
158: this .target = parent.target;
159: this .id = parent.id;
160: this .title = parent.title;
161: this .tooltip = parent.tooltip;
162: this .tooltip = parent.tooltip;
163: this .defaultEntityName = parent.defaultEntityName;
164: this .defaultTitleStyle = parent.defaultTitleStyle;
165: this .defaultSelectedStyle = parent.defaultSelectedStyle;
166: this .defaultWidgetStyle = parent.defaultWidgetStyle;
167: this .defaultTooltipStyle = parent.defaultTooltipStyle;
168: this .defaultMenuItemName = parent.defaultMenuItemName;
169: this .menuItemList = parent.menuItemList;
170: this .menuItemMap = parent.menuItemMap;
171: this .defaultPermissionOperation = parent.defaultPermissionOperation;
172: this .defaultPermissionEntityAction = parent.defaultPermissionEntityAction;
173: this .defaultAssociatedContentId = parent.defaultAssociatedContentId;
174: this .defaultPermissionStatusId = parent.defaultPermissionStatusId;
175: this .defaultPrivilegeEnumId = parent.defaultPrivilegeEnumId;
176: this .defaultHideIfSelected = parent.defaultHideIfSelected;
177: this .orientation = parent.orientation;
178: this .menuWidth = parent.menuWidth;
179: this .defaultCellWidth = parent.defaultCellWidth;
180: this .defaultDisabledTitleStyle = parent.defaultDisabledTitleStyle;
181: this .defaultAlign = parent.defaultAlign;
182: this .defaultAlignStyle = parent.defaultAlignStyle;
183: this .fillStyle = parent.fillStyle;
184: }
185: }
186:
187: this .name = menuElement.getAttribute("name");
188: if (this .type == null || menuElement.hasAttribute("type"))
189: this .type = menuElement.getAttribute("type");
190: if (this .target == null || menuElement.hasAttribute("target"))
191: this .target = menuElement.getAttribute("target");
192: if (this .id == null || menuElement.hasAttribute("id"))
193: this .id = menuElement.getAttribute("id");
194: if (this .title == null || menuElement.hasAttribute("title"))
195: this .setTitle(menuElement.getAttribute("title"));
196: if (this .tooltip == null || menuElement.hasAttribute("tooltip"))
197: this .tooltip = menuElement.getAttribute("tooltip");
198: if (this .defaultEntityName == null
199: || menuElement.hasAttribute("default-entity-name"))
200: this .defaultEntityName = menuElement
201: .getAttribute("default-entity-name");
202: if (this .defaultTitleStyle == null
203: || menuElement.hasAttribute("default-title-style"))
204: this .defaultTitleStyle = menuElement
205: .getAttribute("default-title-style");
206: if (this .defaultSelectedStyle == null
207: || menuElement.hasAttribute("default-selected-style"))
208: this .defaultSelectedStyle = menuElement
209: .getAttribute("default-selected-style");
210: if (this .defaultWidgetStyle == null
211: || menuElement.hasAttribute("default-widget-style"))
212: this .defaultWidgetStyle = menuElement
213: .getAttribute("default-widget-style");
214: if (this .defaultTooltipStyle == null
215: || menuElement.hasAttribute("default-tooltip-style"))
216: this .defaultTooltipStyle = menuElement
217: .getAttribute("default-tooltip-style");
218: if (this .defaultMenuItemName == null
219: || menuElement.hasAttribute("default-menu-item-name"))
220: this .defaultMenuItemName = menuElement
221: .getAttribute("default-menu-item-name");
222: if (this .defaultPermissionOperation == null
223: || menuElement
224: .hasAttribute("default-permission-operation"))
225: this .defaultPermissionOperation = menuElement
226: .getAttribute("default-permission-operation");
227: if (this .defaultPermissionEntityAction == null
228: || menuElement
229: .hasAttribute("default-permission-entity-action"))
230: this .defaultPermissionEntityAction = menuElement
231: .getAttribute("default-permission-entity-action");
232: if (this .defaultPermissionStatusId == null
233: || menuElement
234: .hasAttribute("defaultPermissionStatusId"))
235: this .defaultPermissionStatusId = menuElement
236: .getAttribute("default-permission-status-id");
237: if (this .defaultPrivilegeEnumId == null
238: || menuElement.hasAttribute("defaultPrivilegeEnumId"))
239: this .defaultPrivilegeEnumId = menuElement
240: .getAttribute("default-privilege-enum-id");
241: if (this .defaultAssociatedContentId == null
242: || menuElement
243: .hasAttribute("defaultAssociatedContentId"))
244: this .setDefaultAssociatedContentId(menuElement
245: .getAttribute("default-associated-content-id"));
246: if (this .orientation == null
247: || menuElement.hasAttribute("orientation"))
248: this .orientation = menuElement.getAttribute("orientation");
249: if (this .menuWidth == null
250: || menuElement.hasAttribute("menu-width"))
251: this .menuWidth = menuElement.getAttribute("menu-width");
252: if (this .defaultCellWidth == null
253: || menuElement.hasAttribute("default-cell-width"))
254: this .defaultCellWidth = menuElement
255: .getAttribute("default-cell-width");
256: if (menuElement.hasAttribute("default-hide-if-selected")) {
257: String val = menuElement
258: .getAttribute("default-hide-if-selected");
259: //Debug.logInfo("in ModelMenu, hideIfSelected, val:" + val, module);
260: if (val != null && val.equalsIgnoreCase("true"))
261: defaultHideIfSelected = Boolean.TRUE;
262: else
263: defaultHideIfSelected = Boolean.FALSE;
264: }
265: if (this .defaultDisabledTitleStyle == null
266: || menuElement
267: .hasAttribute("default-disabled-title-style"))
268: this .defaultDisabledTitleStyle = menuElement
269: .getAttribute("default-disabled-title-style");
270: if (this .selectedMenuItemContextFieldName == null
271: || menuElement
272: .hasAttribute("selected-menuitem-context-field-name"))
273: this .selectedMenuItemContextFieldName = new FlexibleMapAccessor(
274: menuElement
275: .getAttribute("selected-menuitem-context-field-name"));
276: if (this .menuContainerStyleExdr == null
277: || menuElement.hasAttribute("menu-container-style"))
278: this .setMenuContainerStyle(menuElement
279: .getAttribute("menu-container-style"));
280: if (this .defaultAlign == null
281: || menuElement.hasAttribute("default-align"))
282: this .defaultAlign = menuElement
283: .getAttribute("default-align");
284: if (this .defaultAlignStyle == null
285: || menuElement.hasAttribute("default-align-style"))
286: this .defaultAlignStyle = menuElement
287: .getAttribute("default-align-style");
288: if (this .fillStyle == null
289: || menuElement.hasAttribute("fill-style"))
290: this .fillStyle = menuElement.getAttribute("fill-style");
291:
292: // read all actions under the "actions" element
293: Element actionsElement = UtilXml.firstChildElement(menuElement,
294: "actions");
295: if (actionsElement != null) {
296: this .actions = ModelMenuAction.readSubActions(this ,
297: actionsElement);
298: }
299:
300: // read in add item defs, add/override one by one using the menuItemList and menuItemMap
301: List itemElements = UtilXml.childElementList(menuElement,
302: "menu-item");
303: Iterator itemElementIter = itemElements.iterator();
304: while (itemElementIter.hasNext()) {
305: Element itemElement = (Element) itemElementIter.next();
306: ModelMenuItem modelMenuItem = new ModelMenuItem(
307: itemElement, this );
308: modelMenuItem = this .addUpdateMenuItem(modelMenuItem);
309: }
310: }
311:
312: /**
313: * add/override modelMenuItem using the menuItemList and menuItemMap
314: *
315: * @return The same ModelMenuItem, or if merged with an existing item, the existing item.
316: */
317: public ModelMenuItem addUpdateMenuItem(ModelMenuItem modelMenuItem) {
318:
319: // not a conditional item, see if a named item exists in Map
320: ModelMenuItem existingMenuItem = (ModelMenuItem) this .menuItemMap
321: .get(modelMenuItem.getName());
322: if (existingMenuItem != null) {
323: // does exist, update the item by doing a merge/override
324: existingMenuItem.mergeOverrideModelMenuItem(modelMenuItem);
325: return existingMenuItem;
326: } else {
327: // does not exist, add to List and Map
328: this .menuItemList.add(modelMenuItem);
329: this .menuItemMap
330: .put(modelMenuItem.getName(), modelMenuItem);
331: return modelMenuItem;
332: }
333: }
334:
335: public ModelMenuItem getModelMenuItemByName(String name) {
336: ModelMenuItem existingMenuItem = (ModelMenuItem) this .menuItemMap
337: .get(name);
338: return existingMenuItem;
339: }
340:
341: public ModelMenuItem getModelMenuItemByContentId(String contentId,
342: Map context) {
343:
344: ModelMenuItem existingMenuItem = null;
345: if (UtilValidate.isEmpty(contentId))
346: return existingMenuItem;
347: Iterator iter = menuItemList.iterator();
348: while (iter.hasNext()) {
349: ModelMenuItem mi = (ModelMenuItem) iter.next();
350: String assocContentId = mi.getAssociatedContentId(context);
351: if (contentId.equals(assocContentId)) {
352: existingMenuItem = mi;
353: break;
354: }
355: }
356: return existingMenuItem;
357: }
358:
359: /**
360: * Renders this menu to a String, i.e. in a text format, as defined with the
361: * MenuStringRenderer implementation.
362: *
363: * @param buffer The StringBuffer that the menu text will be written to
364: * @param context Map containing the menu context; the following are
365: * reserved words in this context: parameters (Map), isError (Boolean),
366: * itemIndex (Integer, for lists only, otherwise null), bshInterpreter,
367: * menuName (String, optional alternate name for menu, defaults to the
368: * value of the name attribute)
369: * @param menuStringRenderer An implementation of the MenuStringRenderer
370: * interface that is responsible for the actual text generation for
371: * different menu elements; implementing you own makes it possible to
372: * use the same menu definitions for many types of menu UIs
373: */
374: public void renderMenuString(StringBuffer buffer, Map context,
375: MenuStringRenderer menuStringRenderer) {
376:
377: boolean passed = true;
378:
379: //Debug.logInfo("in ModelMenu, name:" + this.getName(), module);
380: if (passed) {
381: ModelMenuAction.runSubActions(this .actions, context);
382: if ("simple".equals(this .type)) {
383: this .renderSimpleMenuString(buffer, context,
384: menuStringRenderer);
385: } else {
386: throw new IllegalArgumentException("The type "
387: + this .getType()
388: + " is not supported for menu with name "
389: + this .getName());
390: }
391: }
392: //Debug.logInfo("in ModelMenu, buffer:" + buffer.toString(), module);
393: }
394:
395: public void renderSimpleMenuString(StringBuffer buffer,
396: Map context, MenuStringRenderer menuStringRenderer) {
397: //Iterator menuItemIter = null;
398: //Set alreadyRendered = new TreeSet();
399:
400: // render menu open
401: menuStringRenderer.renderMenuOpen(buffer, context, this );
402:
403: // render formatting wrapper open
404: menuStringRenderer.renderFormatSimpleWrapperOpen(buffer,
405: context, this );
406:
407: // Set the selected menu item from the context
408: this .setCurrentMenuItemName(context);
409:
410: //Debug.logInfo("in ModelMenu, menuItemList:" + menuItemList, module);
411: // render each menuItem row, except hidden & ignored rows
412: //menuStringRenderer.renderFormatSimpleWrapperRows(buffer, context, this);
413: Iterator iter = menuItemList.iterator();
414: while (iter.hasNext()) {
415: ModelMenuItem item = (ModelMenuItem) iter.next();
416: item.renderMenuItemString(buffer, context,
417: menuStringRenderer);
418: }
419:
420: // render formatting wrapper close
421: menuStringRenderer.renderFormatSimpleWrapperClose(buffer,
422: context, this );
423:
424: // render menu close
425: menuStringRenderer.renderMenuClose(buffer, context, this );
426: }
427:
428: public LocalDispatcher getDispacher() {
429: return this .dispatcher;
430: }
431:
432: public GenericDelegator getDelegator() {
433: return this .delegator;
434: }
435:
436: /**
437: * @return
438: */
439: public String getDefaultEntityName() {
440: return this .defaultEntityName;
441: }
442:
443: /**
444: * @return
445: */
446: public String getDefaultAlign() {
447: return this .defaultAlign;
448: }
449:
450: /**
451: * @return
452: */
453: public String getDefaultAlignStyle() {
454: return this .defaultAlignStyle;
455: }
456:
457: /**
458: * @return
459: */
460: public String getDefaultTitleStyle() {
461: return this .defaultTitleStyle;
462: }
463:
464: /**
465: * @return
466: */
467: public String getDefaultDisabledTitleStyle() {
468: return this .defaultDisabledTitleStyle;
469: }
470:
471: /**
472: * @return
473: */
474: public String getDefaultSelectedStyle() {
475: return this .defaultSelectedStyle;
476: }
477:
478: /**
479: * @return
480: */
481: public String getDefaultWidgetStyle() {
482: return this .defaultWidgetStyle;
483: }
484:
485: /**
486: * @return
487: */
488: public String getDefaultTooltipStyle() {
489: return this .defaultTooltipStyle;
490: }
491:
492: /**
493: * @return
494: */
495: public String getDefaultMenuItemName() {
496: return this .defaultMenuItemName;
497: }
498:
499: /**
500: * @return
501: */
502: public String getFillStyle() {
503: return this .fillStyle;
504: }
505:
506: /**
507: * @return
508: */
509: public String getSelectedMenuItemContextFieldName(Map context) {
510: return (String) this .selectedMenuItemContextFieldName
511: .get(context);
512: }
513:
514: /**
515: * @return
516: */
517: public String getCurrentMenuItemName() {
518: if (UtilValidate.isNotEmpty(this .currentMenuItemName))
519: return this .currentMenuItemName;
520: else
521: return this .defaultMenuItemName;
522: }
523:
524: /**
525: * @return
526: */
527: public String getName() {
528: return this .name;
529: }
530:
531: public String getCurrentMenuName(Map context) {
532: return this .name;
533: }
534:
535: /**
536: * @return
537: */
538: public String getId() {
539: return this .id;
540: }
541:
542: /**
543: * @return
544: */
545: public String getTitle(Map context) {
546: return title.expandString(context);
547: }
548:
549: /**
550: * @return
551: */
552: public String getTooltip() {
553: return this .tooltip;
554: }
555:
556: /**
557: * @return
558: */
559: public String getType() {
560: return this .type;
561: }
562:
563: public Interpreter getBshInterpreter(Map context) throws EvalError {
564: Interpreter bsh = (Interpreter) context.get("bshInterpreter");
565: if (bsh == null) {
566: bsh = BshUtil.makeInterpreter(context);
567: context.put("bshInterpreter", bsh);
568: }
569: return bsh;
570: }
571:
572: /**
573: * @param string
574: */
575: public void setDefaultEntityName(String string) {
576: this .defaultEntityName = string;
577: }
578:
579: /**
580: * @param string
581: */
582: public void setDefaultTitleStyle(String string) {
583: this .defaultTitleStyle = string;
584: }
585:
586: /**
587: * @param string
588: */
589: public void setDefaultSelectedStyle(String string) {
590: this .defaultSelectedStyle = string;
591: }
592:
593: /**
594: * @param string
595: */
596: public void setDefaultWidgetStyle(String string) {
597: this .defaultWidgetStyle = string;
598: }
599:
600: /**
601: * @param string
602: */
603: public void setDefaultTooltipStyle(String string) {
604: this .defaultTooltipStyle = string;
605: }
606:
607: /**
608: * @param string
609: */
610: public void setDefaultMenuItemName(String string) {
611: this .defaultMenuItemName = string;
612: }
613:
614: /**
615: * @param string
616: */
617: public void setCurrentMenuItemName(String string) {
618: this .currentMenuItemName = string;
619: }
620:
621: /**
622: * @param context Map containing the menu context
623: */
624: public void setCurrentMenuItemName(Map context) {
625: this .currentMenuItemName = this
626: .getSelectedMenuItemContextFieldName(context);
627: }
628:
629: /**
630: * @param string
631: */
632: public void setName(String string) {
633: this .name = string;
634: }
635:
636: /**
637: * @param string
638: */
639: public void setTarget(String string) {
640: this .target = string;
641: }
642:
643: /**
644: * @param string
645: */
646: public void setId(String string) {
647: this .id = string;
648: }
649:
650: /**
651: * @param string
652: */
653: public void setTitle(String string) {
654: this .title = new FlexibleStringExpander(string);
655: }
656:
657: /**
658: * @param string
659: */
660: public void setTooltip(String string) {
661: this .tooltip = string;
662: }
663:
664: /**
665: * @param string
666: */
667: public void setType(String string) {
668: this .type = string;
669: }
670:
671: /**
672: * @param string
673: */
674: public void setDefaultAssociatedContentId(String string) {
675: this .defaultAssociatedContentId = new FlexibleStringExpander(
676: string);
677: }
678:
679: /**
680: * @param string
681: */
682: public void setMenuContainerStyle(String string) {
683: this .menuContainerStyleExdr = new FlexibleStringExpander(string);
684: }
685:
686: /**
687: * @return
688: */
689: public String getDefaultAssociatedContentId(Map context) {
690: return defaultAssociatedContentId.expandString(context);
691: }
692:
693: /**
694: * @return
695: */
696: public String getMenuContainerStyle(Map context) {
697: return menuContainerStyleExdr.expandString(context);
698: }
699:
700: /**
701: * @param string
702: */
703: public void setDefaultPermissionOperation(String string) {
704: this .defaultPermissionOperation = string;
705: }
706:
707: /**
708: * @return
709: */
710: public String getDefaultPermissionStatusId() {
711: return this .defaultPermissionStatusId;
712: }
713:
714: /**
715: * @param string
716: */
717: public void setDefaultPermissionStatusId(String string) {
718: this .defaultPermissionStatusId = string;
719: }
720:
721: /**
722: * @param string
723: */
724: public void setDefaultPrivilegeEnumId(String string) {
725: this .defaultPrivilegeEnumId = string;
726: }
727:
728: /**
729: * @return
730: */
731: public String getDefaultPrivilegeEnumId() {
732: return this .defaultPrivilegeEnumId;
733: }
734:
735: /**
736: * @param string
737: */
738: public void setOrientation(String string) {
739: this .orientation = string;
740: }
741:
742: /**
743: * @return
744: */
745: public String getOrientation() {
746: return this .orientation;
747: }
748:
749: /**
750: * @param string
751: */
752: public void setMenuWidth(String string) {
753: this .menuWidth = string;
754: }
755:
756: /**
757: * @return
758: */
759: public String getMenuWidth() {
760: return this .menuWidth;
761: }
762:
763: /**
764: * @param string
765: */
766: public void setDefaultCellWidth(String string) {
767: this .defaultCellWidth = string;
768: }
769:
770: /**
771: * @return
772: */
773: public String getDefaultCellWidth() {
774: return this .defaultCellWidth;
775: }
776:
777: /**
778: * @return
779: */
780: public String getDefaultPermissionOperation() {
781: return this .defaultPermissionOperation;
782: }
783:
784: /**
785: * @param string
786: */
787: public void setDefaultPermissionEntityAction(String string) {
788: this .defaultPermissionEntityAction = string;
789: }
790:
791: /**
792: * @return
793: */
794: public String getDefaultPermissionEntityAction() {
795: return this .defaultPermissionEntityAction;
796: }
797:
798: /**
799: * @param val
800: */
801: public void setDefaultHideIfSelected(Boolean val) {
802: this .defaultHideIfSelected = val;
803: }
804:
805: /**
806: * @return
807: */
808: public Boolean getDefaultHideIfSelected() {
809: return this .defaultHideIfSelected;
810: }
811:
812: public ModelMenuItem getCurrentMenuItem() {
813:
814: ModelMenuItem currentMenuItem = (ModelMenuItem) menuItemMap
815: .get(this .currentMenuItemName);
816: if (currentMenuItem == null) {
817: currentMenuItem = (ModelMenuItem) menuItemMap
818: .get(this .defaultMenuItemName);
819: if (currentMenuItem == null && menuItemList.size() > 0) {
820: currentMenuItem = (ModelMenuItem) menuItemList.get(0);
821: }
822: }
823: return currentMenuItem;
824: }
825:
826: public List getMenuItemList() {
827: return menuItemList;
828: }
829:
830: public void dump(StringBuffer buffer) {
831: buffer.append("ModelMenu:" + "\n name=" + this .name
832: + "\n type=" + this .type + "\n target=" + this .target
833: + "\n id=" + this .id + "\n title=" + this .title
834: + "\n tooltip=" + this .tooltip
835: + "\n defaultEntityName=" + this .defaultEntityName
836: + "\n defaultTitleStyle=" + this .defaultTitleStyle
837: + "\n defaultWidgetStyle=" + this .defaultWidgetStyle
838: + "\n defaultTooltipStyle=" + this .defaultTooltipStyle
839: + "\n defaultSelectedStyle="
840: + this .defaultSelectedStyle + "\n defaultMenuItemName="
841: + this .defaultMenuItemName + "\n currentMenuItemName="
842: + this .currentMenuItemName + "\n\n");
843:
844: Iterator iter = menuItemList.iterator();
845: while (iter.hasNext()) {
846: ModelMenuItem menuItem = (ModelMenuItem) iter.next();
847: menuItem.dump(buffer);
848: }
849:
850: }
851:
852: }
|