Salome HOME
Cancel operation work correctly in the case of empty title of the document on the...
[tools/siman.git] / Workspace / Siman / src / org / splat / wapp / TabBar.java
index 0698691e2ea057367442de9a31d586a3ab742311..8759a9bc9622fcaa20832d1dd974d7d524f1b504 100644 (file)
@@ -1,33 +1,51 @@
 package org.splat.wapp;
 
 import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
-import java.util.Vector;
+import java.util.Map;
 
 
+/**
+ * Tab bar class.
+ */
 public class TabBar implements Serializable {
 
-       protected Vector<Item>            menu;               // For making the menu visible as a list of MenuItems
-       protected HashMap<String,Integer> indices;            // Indices of MenuItem objects into this menu
-       protected HashMap<String,String>  disabled;           // Actions of disabled item
-    protected String                  selection;
-
        /**
         * Serial version ID.
         */
        private static final long serialVersionUID = 1851786085512439549L;
 
+       /**
+        * For making the menu visible as a list of MenuItems.
+        */
+       protected transient List<Item>          _menu;
+       /**
+        * Indices of MenuItem objects into this menu.
+        */
+       protected transient Map<String,Integer> _indices;
+       /**
+        * Actions of disabled item.
+        */
+       protected transient Map<String,String>  _disabled;
+    /**
+     * Selected item id.
+     */
+    protected transient String              _selection;
+
 //  ==============================================================================================================================
 //  Constructor
 //  ==============================================================================================================================
 
+    /**
+     * Empty tab bar constuctor.
+     */
     public TabBar () {
-//  ----------------
-      menu      = new Vector<Item>();
-      indices   = new HashMap<String,Integer>();
-      disabled  = new HashMap<String,String>();
-      selection = null;
+      _menu      = new ArrayList<Item>();
+      _indices   = new HashMap<String,Integer>();
+      _disabled  = new HashMap<String,String>();
+      _selection = null;
     }
 
 //  ==============================================================================================================================
@@ -36,12 +54,11 @@ public class TabBar implements Serializable {
 /**
  * Adds an item to this tab-bar.
  * @param name the name of the item added to this bar.
- * @param item the added item
+ * @param url the added item url
  */
-    public void addItem (String name, String url) {
-//  ---------------------------------------------
-      indices.put(name, menu.size());
-      menu.add( new Item(name, url) );
+    public void addItem (final String name, final String url) {
+      _indices.put(name, _menu.size());
+      _menu.add( new Item(name, url) );
     }
 
 /**
@@ -49,21 +66,21 @@ public class TabBar implements Serializable {
  * @return the list of items of this bar.
  */
     public List<Item> asList () {
-//  ---------------------------
-      return menu;
+      return _menu;
     }
 
 /**
  * Disables the item of given name.
  * @param name the name of the item.
  */
-    public void disables (String name) {
-//  ----------------------------------
-      String action = disabled.get(name);
-      Item   item   = menu.get(indices.get(name));
-
-      if (action != null) return;             // Item already disabled
-      disabled.put(name, item.getAction());   // Saves the current action for latter enabling
+    public void disables (final String name) {
+      String action = _disabled.get(name);
+      Item   item   = _menu.get(_indices.get(name));
+
+      if (action != null) {
+               return;             // Item already disabled
+       }
+      _disabled.put(name, item.getAction());   // Saves the current action for latter enabling
       item.action(null);
     }
 
@@ -71,13 +88,14 @@ public class TabBar implements Serializable {
  * Enables the item of given name, if previously disabled.
  * @param name the name of the item.
  */
-    public void enables (String name) {
-//  ---------------------------------
-      String action = disabled.get(name);
-      Item   item   = menu.get(indices.get(name));
-
-      if (action == null) return;             // Item not previously disabled
-      disabled.remove(name);
+    public void enables (final String name) {
+      String action = _disabled.get(name);
+      Item   item   = _menu.get(_indices.get(name));
+
+      if (action == null) {
+               return;             // Item not previously disabled
+       }
+      _disabled.remove(name);
       item.action(action);
     }
 
@@ -87,21 +105,23 @@ public class TabBar implements Serializable {
  * @return the name of the currently selected item of this menu.
  */
     public String getSelection () {
-//  -----------------------------
-      return selection;        // May be null
+      return _selection;        // May be null
     }
 
 /**
  * Sets the given menu-item as selected.
  * @param name the name of the selected menu-item.
  */
-    public void selects (String name) {
-//  ---------------------------------
-      Integer  newdex = indices.get(name);
-
-      if (selection != null) menu.get(indices.get(selection)).unselect();
-      if (newdex    == null) return;
-      menu.get(newdex).select();
-      selection = name;
+    public void selects (final String name) {
+      Integer  newdex = _indices.get(name);
+
+      if (_selection != null) {
+               _menu.get(_indices.get(_selection)).unselect();
+       }
+      if (newdex    == null) {
+               return;
+       }
+      _menu.get(newdex).select();
+      _selection = name;
     }
 }
\ No newline at end of file