-// ==============================================================================================================================
-// Constructor
-// ==============================================================================================================================
-
- public PopupMenu () {
-// -------------------
- _width = 186; // Includes borders (2px) and shadow (4px)
- _height = 2; // Top and bottom border
- }
-
-// ==============================================================================================================================
-// Member functions
-// ==============================================================================================================================
-
- public void addItem (String name, PopupItem item) {
-// -------------------------------------------------
- item._width = 180;
- item._height = 22; // Height of image.selected.png background image
- this._height += item._height;
- super.addItem(name, item);
- }
-
- public void addSeparator () {
-// ---------------------------
- PopupItem item = new PopupItem();
- item._width = 180;
- item._height = 8;
- this._height += item._height;
- super.addItem("", item);
- }
-
- @SuppressWarnings({"rawtypes","unchecked"})
- public List<PopupItem> asList () {
-// --------------------------------
- return (List)_items;
- }
-
- public PopupItem item (String name) {
-// -----------------------------------
- return (PopupItem)_items.get(_indices.get(name));
- }
+ // ==============================================================================================================================
+ // Constructor
+ // ==============================================================================================================================
+
+ /**
+ * Default constructor.
+ */
+ public PopupMenu() {
+ super();
+ _width = 186; // Includes borders (2px) and shadow (4px)
+ _height = 2; // Top and bottom border
+ }
+
+ // ==============================================================================================================================
+ // Member functions
+ // ==============================================================================================================================
+
+ /**
+ * Add a menu item.
+ *
+ * @param name
+ * the item name
+ * @param item
+ * the item to add
+ */
+ public void addItem(final String name, final PopupItem item) {
+ item._width = 180;
+ item._height = 22; // Height of image.selected.png background image
+ this._height += item._height;
+ super.addItem(name, item);
+ }
+
+ /**
+ * Insert an items separator into the menu.
+ */
+ public void addSeparator() {
+ PopupItem item = new PopupItem();
+ item._width = 180;
+ item._height = 8;
+ this._height += item._height;
+ super.addItem("", item);
+ }
+
+ /**
+ * Get the menu as a list of menu items.
+ *
+ * @return the list of menu items
+ */
+ @SuppressWarnings(Constants.UNCHECKED)
+ public List<PopupItem> asList() {
+ return (List) _items;
+ }
+
+ /**
+ * Get menu item by name.
+ *
+ * @param name
+ * the menu item name
+ * @return the menu item
+ */
+ public PopupItem item(final String name) {
+ return (PopupItem) _items.get(_indices.get(name));
+ }
+
+ /**
+ * Check if this menu contains the given item.
+ *
+ * @param name
+ * the item name
+ * @return true if this menu contains the given item.
+ */
+ public boolean hasItem(final String name) {
+ return _indices.containsKey(name);
+ }