KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > widget > menu > ModelMenu


1 /*
2  * $Id: ModelMenu.java 5660 2005-09-07 19:53:13Z jonesde $
3  *
4  * Copyright (c) 2003 The Open For Business Project - www.ofbiz.org
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
21  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */

24 package org.ofbiz.widget.menu;
25
26 import java.util.HashMap JavaDoc;
27 import java.util.Iterator JavaDoc;
28 import java.util.LinkedList JavaDoc;
29 import java.util.List JavaDoc;
30 import java.util.Map JavaDoc;
31
32 import org.ofbiz.base.util.BshUtil;
33 import org.ofbiz.base.util.Debug;
34 import org.ofbiz.base.util.UtilValidate;
35 import org.ofbiz.base.util.UtilXml;
36 import org.ofbiz.base.util.string.FlexibleStringExpander;
37 import org.ofbiz.base.util.collections.FlexibleMapAccessor;
38 import org.ofbiz.entity.GenericDelegator;
39 import org.ofbiz.service.LocalDispatcher;
40 import org.w3c.dom.Element JavaDoc;
41
42 import bsh.EvalError;
43 import bsh.Interpreter;
44
45 /**
46  * Widget Library - Menu model class
47  *
48  * @author <a HREF="mailto:jonesde@ofbiz.org">David E. Jones</a>
49  * @author <a HREF="mailto:byersa@automationgroups.com">Al Byers</a>
50  * @version $Rev: 5660 $
51  * @since 2.2
52  */

53 public class ModelMenu {
54
55     public static final String JavaDoc module = ModelMenu.class.getName();
56
57     protected GenericDelegator delegator;
58     protected LocalDispatcher dispatcher;
59
60     protected String JavaDoc name;
61     protected String JavaDoc type;
62     protected String JavaDoc target;
63     protected String JavaDoc title;
64     protected String JavaDoc tooltip;
65     protected String JavaDoc defaultEntityName;
66     protected String JavaDoc defaultTitleStyle;
67     protected String JavaDoc defaultWidgetStyle;
68     protected String JavaDoc defaultTooltipStyle;
69     protected String JavaDoc defaultSelectedStyle;
70     protected String JavaDoc defaultMenuItemName;
71     protected String JavaDoc currentMenuItemName;
72     protected String JavaDoc defaultPermissionOperation;
73     protected String JavaDoc defaultPermissionEntityAction;
74     protected FlexibleStringExpander defaultAssociatedContentId;
75     protected String JavaDoc defaultPermissionStatusId;
76     protected String JavaDoc defaultPrivilegeEnumId;
77     protected String JavaDoc orientation = "horizontal";
78     protected String JavaDoc menuWidth;
79     protected String JavaDoc defaultCellWidth;
80     protected Boolean JavaDoc defaultHideIfSelected;
81     protected String JavaDoc defaultDisabledTitleStyle;
82     protected FlexibleMapAccessor selectedMenuItemContextFieldName;
83     protected FlexibleStringExpander menuContainerStyleExdr;
84     protected String JavaDoc defaultAlign;
85     protected String JavaDoc defaultAlignStyle;
86     protected String JavaDoc fillStyle;
87
88     /** This List will contain one copy of each item for each item name in the order
89      * they were encountered in the service, entity, or menu definition; item definitions
90      * with constraints will also be in this list but may appear multiple times for the same
91      * item name.
92      *
93      * When rendering the menu the order in this list should be following and it should not be
94      * necessary to use the Map. The Map is used when loading the menu definition to keep the
95      * list clean and implement the override features for item definitions.
96      */

97     protected List JavaDoc menuItemList = new LinkedList JavaDoc();
98
99     /** This Map is keyed with the item name and has a ModelMenuItem for the value; items
100      * with conditions will not be put in this Map so item definition overrides for items
101      * with conditions is not possible.
102      */

103     protected Map JavaDoc menuItemMap = new HashMap JavaDoc();
104     
105     protected List JavaDoc actions;
106
107     
108    // ===== CONSTRUCTORS =====
109
/** Default Constructor */
110     public ModelMenu() {}
111
112     /** XML Constructor */
113     public ModelMenu(Element JavaDoc menuElement, GenericDelegator delegator, LocalDispatcher dispatcher) {
114         this.delegator = delegator;
115         this.dispatcher = dispatcher;
116
117         // check if there is a parent menu to inherit from
118
String JavaDoc parentResource = menuElement.getAttribute("extends-resource");
119         String JavaDoc parentMenu = menuElement.getAttribute("extends");
120         //TODO: Modify this to allow for extending a menu with the same name but different resource
121
if (parentMenu.length() > 0 && !parentMenu.equals(menuElement.getAttribute("name"))) {
122             ModelMenu parent = null;
123             // check if we have a resource name (part of the string before the ?)
124
if (parentResource.length() > 0) {
125                 try {
126                     parent = MenuFactory.getMenuFromClass(parentResource, parentMenu, delegator, dispatcher);
127                 } catch (Exception JavaDoc e) {
128                     Debug.logError(e, "Failed to load parent menu definition '" + parentMenu + "' at resource '" + parentResource + "'", module);
129                 }
130             } else {
131                 // try to find a menu definition in the same file
132
Element JavaDoc rootElement = menuElement.getOwnerDocument().getDocumentElement();
133                 List JavaDoc menuElements = UtilXml.childElementList(rootElement, "menu");
134                 //Uncomment below to add support for abstract menus
135
//menuElements.addAll(UtilXml.childElementList(rootElement, "abstract-menu"));
136
Iterator JavaDoc menuElementIter = menuElements.iterator();
137                 while (menuElementIter.hasNext()) {
138                     Element JavaDoc menuElementEntry = (Element JavaDoc) menuElementIter.next();
139                     if (menuElementEntry.getAttribute("name").equals(parentMenu)) {
140                         parent = new ModelMenu(menuElementEntry, delegator, dispatcher);
141                         break;
142                     }
143                 }
144                 if (parent == null) {
145                     Debug.logError("Failed to find parent menu defenition '" + parentMenu + "' in same document.", module);
146                 }
147             }
148
149             if (parent != null) {
150                 this.type = parent.type;
151                 this.target = parent.target;
152                 this.title = parent.title;
153                 this.tooltip = parent.tooltip;
154                 this.tooltip = parent.tooltip;
155                 this.defaultEntityName = parent.defaultEntityName;
156                 this.defaultTitleStyle = parent.defaultTitleStyle;
157                 this.defaultSelectedStyle = parent.defaultSelectedStyle;
158                 this.defaultWidgetStyle = parent.defaultWidgetStyle;
159                 this.defaultTooltipStyle = parent.defaultTooltipStyle;
160                 this.defaultMenuItemName = parent.defaultMenuItemName;
161                 this.menuItemList = parent.menuItemList;
162                 this.menuItemMap = parent.menuItemMap;
163                 this.defaultPermissionOperation = parent.defaultPermissionOperation;
164                 this.defaultPermissionEntityAction = parent.defaultPermissionEntityAction;
165                 this.defaultAssociatedContentId = parent.defaultAssociatedContentId;
166                 this.defaultPermissionStatusId = parent.defaultPermissionStatusId;
167                 this.defaultPrivilegeEnumId = parent.defaultPrivilegeEnumId;
168                 this.defaultHideIfSelected = parent.defaultHideIfSelected;
169                 this.orientation = parent.orientation;
170                 this.menuWidth = parent.menuWidth;
171                 this.defaultCellWidth = parent.defaultCellWidth;
172                 this.defaultDisabledTitleStyle = parent.defaultDisabledTitleStyle;
173                 this.defaultAlign = parent.defaultAlign;
174                 this.defaultAlignStyle = parent.defaultAlignStyle;
175                 this.fillStyle = parent.fillStyle;
176             }
177         }
178
179         this.name = menuElement.getAttribute("name");
180         if (this.type == null || menuElement.hasAttribute("type"))
181             this.type = menuElement.getAttribute("type");
182         if (this.target == null || menuElement.hasAttribute("target"))
183             this.target = menuElement.getAttribute("target");
184         if (this.title == null || menuElement.hasAttribute("title"))
185             this.title = menuElement.getAttribute("title");
186         if (this.tooltip == null || menuElement.hasAttribute("tooltip"))
187             this.tooltip = menuElement.getAttribute("tooltip");
188         if (this.defaultEntityName == null || menuElement.hasAttribute("default-entity-name"))
189             this.defaultEntityName = menuElement.getAttribute("default-entity-name");
190         if (this.defaultTitleStyle == null || menuElement.hasAttribute("default-title-style"))
191             this.defaultTitleStyle = menuElement.getAttribute("default-title-style");
192         if (this.defaultSelectedStyle == null || menuElement.hasAttribute("default-selected-style"))
193             this.defaultSelectedStyle = menuElement.getAttribute("default-selected-style");
194         if (this.defaultWidgetStyle == null || menuElement.hasAttribute("default-widget-style"))
195             this.defaultWidgetStyle = menuElement.getAttribute("default-widget-style");
196         if (this.defaultTooltipStyle == null || menuElement.hasAttribute("default-tooltip-style"))
197             this.defaultTooltipStyle = menuElement.getAttribute("default-tooltip-style");
198         if (this.defaultMenuItemName == null || menuElement.hasAttribute("default-menu-item-name"))
199             this.defaultMenuItemName = menuElement.getAttribute("default-menu-item-name");
200         if (this.defaultPermissionOperation == null || menuElement.hasAttribute("default-permission-operation"))
201             this.defaultPermissionOperation = menuElement.getAttribute("default-permission-operation");
202         if (this.defaultPermissionEntityAction == null || menuElement.hasAttribute("default-permission-entity-action"))
203             this.defaultPermissionEntityAction = menuElement.getAttribute("default-permission-entity-action");
204         if (this.defaultPermissionStatusId == null || menuElement.hasAttribute("defaultPermissionStatusId"))
205             this.defaultPermissionStatusId = menuElement.getAttribute("default-permission-status-id");
206         if (this.defaultPrivilegeEnumId == null || menuElement.hasAttribute("defaultPrivilegeEnumId"))
207             this.defaultPrivilegeEnumId = menuElement.getAttribute("default-privilege-enum-id");
208         if (this.defaultAssociatedContentId == null || menuElement.hasAttribute("defaultAssociatedContentId"))
209             this.setDefaultAssociatedContentId( menuElement.getAttribute("default-associated-content-id"));
210         if (this.orientation == null || menuElement.hasAttribute("orientation"))
211             this.orientation = menuElement.getAttribute("orientation");
212         if (this.menuWidth == null || menuElement.hasAttribute("menu-width"))
213             this.menuWidth = menuElement.getAttribute("menu-width");
214         if (this.defaultCellWidth == null || menuElement.hasAttribute("default-cell-width"))
215             this.defaultCellWidth = menuElement.getAttribute("default-cell-width");
216         if (menuElement.hasAttribute("default-hide-if-selected")) {
217             String JavaDoc val = menuElement.getAttribute("default-hide-if-selected");
218                 //Debug.logInfo("in ModelMenu, hideIfSelected, val:" + val, module);
219
if (val != null && val.equalsIgnoreCase("true"))
220                 defaultHideIfSelected = new Boolean JavaDoc(true);
221             else
222                 defaultHideIfSelected = new Boolean JavaDoc(false);
223         }
224         if (this.defaultDisabledTitleStyle == null || menuElement.hasAttribute("default-disabled-title-style"))
225             this.defaultDisabledTitleStyle = menuElement.getAttribute("default-disabled-title-style");
226         if (this.selectedMenuItemContextFieldName == null || menuElement.hasAttribute("selected-menuitem-context-field-name"))
227             this.selectedMenuItemContextFieldName = new FlexibleMapAccessor(menuElement.getAttribute("selected-menuitem-context-field-name"));
228         if (this.menuContainerStyleExdr == null || menuElement.hasAttribute("menu-container-style"))
229             this.setMenuContainerStyle(menuElement.getAttribute("menu-container-style"));
230         if (this.defaultAlign == null || menuElement.hasAttribute("default-align"))
231             this.defaultAlign = menuElement.getAttribute("default-align");
232         if (this.defaultAlignStyle == null || menuElement.hasAttribute("default-align-style"))
233             this.defaultAlignStyle = menuElement.getAttribute("default-align-style");
234         if (this.fillStyle == null || menuElement.hasAttribute("fill-style"))
235             this.fillStyle = menuElement.getAttribute("fill-style");
236
237         // read all actions under the "actions" element
238
Element JavaDoc actionsElement = UtilXml.firstChildElement(menuElement, "actions");
239         if (actionsElement != null) {
240             this.actions = ModelMenuAction.readSubActions(this, actionsElement);
241         }
242
243         // read in add item defs, add/override one by one using the menuItemList and menuItemMap
244
List JavaDoc itemElements = UtilXml.childElementList(menuElement, "menu-item");
245         Iterator JavaDoc itemElementIter = itemElements.iterator();
246         while (itemElementIter.hasNext()) {
247             Element JavaDoc itemElement = (Element JavaDoc) itemElementIter.next();
248             ModelMenuItem modelMenuItem = new ModelMenuItem(itemElement, this);
249             modelMenuItem = this.addUpdateMenuItem(modelMenuItem);
250         }
251     }
252     /**
253      * add/override modelMenuItem using the menuItemList and menuItemMap
254      *
255      * @return The same ModelMenuItem, or if merged with an existing item, the existing item.
256      */

257     public ModelMenuItem addUpdateMenuItem(ModelMenuItem modelMenuItem) {
258
259             // not a conditional item, see if a named item exists in Map
260
ModelMenuItem existingMenuItem = (ModelMenuItem) this.menuItemMap.get(modelMenuItem.getName());
261             if (existingMenuItem != null) {
262                 // does exist, update the item by doing a merge/override
263
existingMenuItem.mergeOverrideModelMenuItem(modelMenuItem);
264                 return existingMenuItem;
265             } else {
266                 // does not exist, add to List and Map
267
this.menuItemList.add(modelMenuItem);
268                 this.menuItemMap.put(modelMenuItem.getName(), modelMenuItem);
269                 return modelMenuItem;
270             }
271     }
272
273     public ModelMenuItem getModelMenuItemByName(String JavaDoc name) {
274             ModelMenuItem existingMenuItem = (ModelMenuItem) this.menuItemMap.get(name);
275             return existingMenuItem;
276     }
277
278     public ModelMenuItem getModelMenuItemByContentId(String JavaDoc contentId, Map JavaDoc context) {
279
280         ModelMenuItem existingMenuItem = null;
281         if (UtilValidate.isEmpty(contentId))
282             return existingMenuItem;
283         Iterator JavaDoc iter = menuItemList.iterator();
284         while (iter.hasNext()) {
285             ModelMenuItem mi = (ModelMenuItem) iter.next();
286             String JavaDoc assocContentId = mi.getAssociatedContentId(context);
287             if (contentId.equals(assocContentId)) {
288                 existingMenuItem = mi;
289                 break;
290             }
291         }
292             return existingMenuItem;
293     }
294
295     /**
296      * Renders this menu to a String, i.e. in a text format, as defined with the
297      * MenuStringRenderer implementation.
298      *
299      * @param buffer The StringBuffer that the menu text will be written to
300      * @param context Map containing the menu context; the following are
301      * reserved words in this context: parameters (Map), isError (Boolean),
302      * itemIndex (Integer, for lists only, otherwise null), bshInterpreter,
303      * menuName (String, optional alternate name for menu, defaults to the
304      * value of the name attribute)
305      * @param menuStringRenderer An implementation of the MenuStringRenderer
306      * interface that is responsible for the actual text generation for
307      * different menu elements; implementing you own makes it possible to
308      * use the same menu definitions for many types of menu UIs
309      */

310     public void renderMenuString(StringBuffer JavaDoc buffer, Map JavaDoc context, MenuStringRenderer menuStringRenderer) {
311         
312         boolean passed = true;
313
314             //Debug.logInfo("in ModelMenu, name:" + this.getName(), module);
315
if (passed) {
316             ModelMenuAction.runSubActions(this.actions, context);
317             if ("simple".equals(this.type)) {
318                 this.renderSimpleMenuString(buffer, context, menuStringRenderer);
319             } else {
320                 throw new IllegalArgumentException JavaDoc("The type " + this.getType() + " is not supported for menu with name " + this.getName());
321             }
322         }
323             //Debug.logInfo("in ModelMenu, buffer:" + buffer.toString(), module);
324
}
325
326     public void renderSimpleMenuString(StringBuffer JavaDoc buffer, Map JavaDoc context, MenuStringRenderer menuStringRenderer) {
327         //Iterator menuItemIter = null;
328
//Set alreadyRendered = new TreeSet();
329

330         // render menu open
331
menuStringRenderer.renderMenuOpen(buffer, context, this);
332
333         // render formatting wrapper open
334
menuStringRenderer.renderFormatSimpleWrapperOpen(buffer, context, this);
335
336             //Debug.logInfo("in ModelMenu, menuItemList:" + menuItemList, module);
337
// render each menuItem row, except hidden & ignored rows
338
//menuStringRenderer.renderFormatSimpleWrapperRows(buffer, context, this);
339
Iterator JavaDoc iter = menuItemList.iterator();
340         while (iter.hasNext()) {
341             ModelMenuItem item = (ModelMenuItem)iter.next();
342             item.renderMenuItemString(buffer, context, menuStringRenderer);
343         }
344
345         // render formatting wrapper close
346
menuStringRenderer.renderFormatSimpleWrapperClose(buffer, context, this);
347
348         // render menu close
349
menuStringRenderer.renderMenuClose(buffer, context, this);
350     }
351
352
353     public LocalDispatcher getDispacher() {
354         return this.dispatcher;
355     }
356
357     public GenericDelegator getDelegator() {
358         return this.delegator;
359     }
360
361     /**
362      * @return
363      */

364     public String JavaDoc getDefaultEntityName() {
365         return this.defaultEntityName;
366     }
367
368     /**
369      * @return
370      */

371     public String JavaDoc getDefaultAlign() {
372         return this.defaultAlign;
373     }
374
375     /**
376      * @return
377      */

378     public String JavaDoc getDefaultAlignStyle() {
379         return this.defaultAlignStyle;
380     }
381
382
383     /**
384      * @return
385      */

386     public String JavaDoc getDefaultTitleStyle() {
387         return this.defaultTitleStyle;
388     }
389
390     /**
391      * @return
392      */

393     public String JavaDoc getDefaultDisabledTitleStyle() {
394         return this.defaultDisabledTitleStyle;
395     }
396
397     /**
398      * @return
399      */

400     public String JavaDoc getDefaultSelectedStyle() {
401         return this.defaultSelectedStyle;
402     }
403
404     /**
405      * @return
406      */

407     public String JavaDoc getDefaultWidgetStyle() {
408         return this.defaultWidgetStyle;
409     }
410
411     /**
412      * @return
413      */

414     public String JavaDoc getDefaultTooltipStyle() {
415         return this.defaultTooltipStyle;
416     }
417
418     /**
419      * @return
420      */

421     public String JavaDoc getDefaultMenuItemName() {
422         return this.defaultMenuItemName;
423     }
424
425     /**
426      * @return
427      */

428     public String JavaDoc getFillStyle() {
429         return this.fillStyle;
430     }
431
432     /**
433      * @return
434      */

435     public String JavaDoc getSelectedMenuItemContextFieldName(Map JavaDoc context) {
436         return (String JavaDoc)this.selectedMenuItemContextFieldName.get(context);
437     }
438
439     /**
440      * @return
441      */

442     public String JavaDoc getCurrentMenuItemName() {
443         if (UtilValidate.isNotEmpty(this.currentMenuItemName))
444             return this.currentMenuItemName;
445         else
446             return this.defaultMenuItemName;
447     }
448
449
450     /**
451      * @return
452      */

453     public String JavaDoc getName() {
454         return this.name;
455     }
456
457     public String JavaDoc getCurrentMenuName(Map JavaDoc context) {
458         return this.name;
459     }
460
461
462     /**
463      * @return
464      */

465     public String JavaDoc getTitle() {
466         return this.title;
467     }
468
469     /**
470      * @return
471      */

472     public String JavaDoc getTooltip() {
473         return this.tooltip;
474     }
475
476     /**
477      * @return
478      */

479     public String JavaDoc getType() {
480         return this.type;
481     }
482
483     public Interpreter getBshInterpreter(Map JavaDoc context) throws EvalError {
484         Interpreter bsh = (Interpreter) context.get("bshInterpreter");
485         if (bsh == null) {
486             bsh = BshUtil.makeInterpreter(context);
487             context.put("bshInterpreter", bsh);
488         }
489         return bsh;
490     }
491
492     /**
493      * @param string
494      */

495     public void setDefaultEntityName(String JavaDoc string) {
496         this.defaultEntityName = string;
497     }
498
499
500     /**
501      * @param string
502      */

503     public void setDefaultTitleStyle(String JavaDoc string) {
504         this.defaultTitleStyle = string;
505     }
506
507     /**
508      * @param string
509      */

510     public void setDefaultSelectedStyle(String JavaDoc string) {
511         this.defaultSelectedStyle = string;
512     }
513
514     /**
515      * @param string
516      */

517     public void setDefaultWidgetStyle(String JavaDoc string) {
518         this.defaultWidgetStyle = string;
519     }
520
521     /**
522      * @param string
523      */

524     public void setDefaultTooltipStyle(String JavaDoc string) {
525         this.defaultTooltipStyle = string;
526     }
527
528     /**
529      * @param string
530      */

531     public void setDefaultMenuItemName(String JavaDoc string) {
532         this.defaultMenuItemName = string;
533     }
534
535     /**
536      * @param string
537      */

538     public void setCurrentMenuItemName(String JavaDoc string) {
539         this.currentMenuItemName = string;
540     }
541
542
543     /**
544      * @param string
545      */

546     public void setName(String JavaDoc string) {
547         this.name = string;
548     }
549
550     /**
551      * @param string
552      */

553     public void setTarget(String JavaDoc string) {
554         this.target = string;
555     }
556
557     /**
558      * @param string
559      */

560     public void setTitle(String JavaDoc string) {
561         this.title = string;
562     }
563
564     /**
565      * @param string
566      */

567     public void setTooltip(String JavaDoc string) {
568         this.tooltip = string;
569     }
570
571     /**
572      * @param string
573      */

574     public void setType(String JavaDoc string) {
575         this.type = string;
576     }
577
578     /**
579      * @param string
580      */

581     public void setDefaultAssociatedContentId(String JavaDoc string) {
582         this.defaultAssociatedContentId = new FlexibleStringExpander(string);
583     }
584
585     /**
586      * @param string
587      */

588     public void setMenuContainerStyle(String JavaDoc string) {
589         this.menuContainerStyleExdr = new FlexibleStringExpander(string);
590     }
591
592     /**
593      * @return
594      */

595     public String JavaDoc getDefaultAssociatedContentId(Map JavaDoc context) {
596         return defaultAssociatedContentId.expandString(context);
597     }
598     /**
599      * @return
600      */

601     public String JavaDoc getMenuContainerStyle(Map JavaDoc context) {
602         return menuContainerStyleExdr.expandString(context);
603     }
604
605     /**
606      * @param string
607      */

608     public void setDefaultPermissionOperation(String JavaDoc string) {
609         this.defaultPermissionOperation = string;
610     }
611
612     /**
613      * @return
614      */

615     public String JavaDoc getDefaultPermissionStatusId() {
616         return this.defaultPermissionStatusId;
617     }
618
619     /**
620      * @param string
621      */

622     public void setDefaultPermissionStatusId(String JavaDoc string) {
623         this.defaultPermissionStatusId = string;
624     }
625
626     /**
627      * @param string
628      */

629     public void setDefaultPrivilegeEnumId(String JavaDoc string) {
630         this.defaultPrivilegeEnumId = string;
631     }
632
633     /**
634      * @return
635      */

636     public String JavaDoc getDefaultPrivilegeEnumId() {
637         return this.defaultPrivilegeEnumId;
638     }
639
640     /**
641      * @param string
642      */

643     public void setOrientation(String JavaDoc string) {
644         this.orientation = string;
645     }
646
647     /**
648      * @return
649      */

650     public String JavaDoc getOrientation() {
651         return this.orientation;
652     }
653
654     /**
655      * @param string
656      */

657     public void setMenuWidth(String JavaDoc string) {
658         this.menuWidth = string;
659     }
660
661     /**
662      * @return
663      */

664     public String JavaDoc getMenuWidth() {
665         return this.menuWidth;
666     }
667
668     /**
669      * @param string
670      */

671     public void setDefaultCellWidth(String JavaDoc string) {
672         this.defaultCellWidth = string;
673     }
674
675     /**
676      * @return
677      */

678     public String JavaDoc getDefaultCellWidth() {
679         return this.defaultCellWidth;
680     }
681
682     /**
683      * @return
684      */

685     public String JavaDoc getDefaultPermissionOperation() {
686         return this.defaultPermissionOperation;
687     }
688
689     /**
690      * @param string
691      */

692     public void setDefaultPermissionEntityAction(String JavaDoc string) {
693         this.defaultPermissionEntityAction = string;
694     }
695
696     /**
697      * @return
698      */

699     public String JavaDoc getDefaultPermissionEntityAction() {
700         return this.defaultPermissionEntityAction;
701     }
702
703     /**
704      * @param boolean
705      */

706     public void setDefaultHideIfSelected(Boolean JavaDoc val) {
707         this.defaultHideIfSelected = val;
708     }
709
710     /**
711      * @return
712      */

713     public Boolean JavaDoc getDefaultHideIfSelected() {
714         return this.defaultHideIfSelected;
715     }
716
717     public ModelMenuItem getCurrentMenuItem() {
718         
719         ModelMenuItem currentMenuItem = (ModelMenuItem)menuItemMap.get(this.currentMenuItemName);
720         if (currentMenuItem == null) {
721             currentMenuItem = (ModelMenuItem)menuItemMap.get(this.defaultMenuItemName);
722             if (currentMenuItem == null && menuItemList.size() > 0) {
723                 currentMenuItem = (ModelMenuItem)menuItemList.get(0);
724             }
725         }
726         return currentMenuItem;
727     }
728
729     public List JavaDoc getMenuItemList() {
730         return menuItemList;
731     }
732
733     public void dump(StringBuffer JavaDoc buffer ) {
734         buffer.append("ModelMenu:"
735             + "\n name=" + this.name
736             + "\n type=" + this.type
737             + "\n target=" + this.target
738             + "\n title=" + this.title
739             + "\n tooltip=" + this.tooltip
740             + "\n defaultEntityName=" + this.defaultEntityName
741             + "\n defaultTitleStyle=" + this.defaultTitleStyle
742             + "\n defaultWidgetStyle=" + this.defaultWidgetStyle
743             + "\n defaultTooltipStyle=" + this.defaultTooltipStyle
744             + "\n defaultSelectedStyle=" + this.defaultSelectedStyle
745             + "\n defaultMenuItemName=" + this.defaultMenuItemName
746             + "\n currentMenuItemName=" + this.currentMenuItemName
747             + "\n\n");
748      
749         Iterator JavaDoc iter = menuItemList.iterator();
750         while (iter.hasNext()) {
751             ModelMenuItem menuItem = (ModelMenuItem)iter.next();
752             menuItem.dump(buffer);
753         }
754             
755         return;
756     }
757
758 }
759
Popular Tags