1 package org.splat.wapp;
3 import org.splat.wapp.MenuItem.Group;
6 * Abstract subclass implementing the base services of two levels menus.
7 * SlidMenus are supposed (but not necessarily) behaving as follows:
9 * <li>Only one first-level menu-item is open at a time</li>
10 * <li>When selecting a closed first-level item, the actual open one, if exist, is closed before opening the new selected one,
11 * making first-level items "sliding"</li>
13 * The SlidMenu is implemented as an ordered flat list of named menu-items of type first-level, so called Group,
14 * and second-level, or SubItem (these both latter are subclasses of MenuItem). SubItems must follow in the list the Group
15 * to which they belong. A first-level item can also be empty (not containing any SubItem), so simply called Item.<br/>
17 * As such, a SlidMenu is built by calling, in the appropriate order, addItem(), addGroup() and addSubItem(). As any menu,
18 * after its creation, a SlidMenu is in Unselected state. The user selection is then set (and changed) by the name of its
19 * corresponding menu-item through the selects() function.<br/>
20 * One additional function, clear(), allows concrete subclasses of this abstract class to empty the menu before
21 * rebuilding it following a user selection in the implementation of the overridden selects() function.
23 * @author Daniel Brunier-Coulin
25 public class SlidMenu extends Menu {
27 // ==============================================================================================================================
29 // ==============================================================================================================================
31 public SlidMenu (final String name) {
32 // -----------------------------
35 public SlidMenu (final String name, final String scope) {
36 // -------------------------------------------
40 // ==============================================================================================================================
42 // ==============================================================================================================================
44 public void addGroup (final String name, final String label, final String icon, final String url) {
45 // -------------------------------------------------------------------------
46 this.addItem(name, new MenuItem.Group(label,icon,url) );
49 public void addItem (final String name, final String label, final String icon, final String url) {
50 // ------------------------------------------------------------------------
51 this.addItem(name, new MenuItem(label,icon,url) );
54 public void addSubItem (final String name, final String label, final String icon, final String url) {
55 // ---------------------------------------------------------------------------
56 MenuItem last = _menu.lastElement();
57 if (last instanceof Group) {
61 this.addItem(name, new MenuItem.SubItem(label,icon,url) );
64 // ==============================================================================================================================
66 // ==============================================================================================================================
68 protected void clear () {
69 // -----------------------