Index: source/class/pf/Application.js
===================================================================
--- source/class/pf/Application.js	(revision 25)
+++ source/class/pf/Application.js	(revision 26)
@@ -383,4 +383,45 @@
 }
 
+function viewMenuCB(ev)
+{
+    var explorer_is_seen;
+    
+    if (this.entity_tree.isSeeable()) {
+        explorer_is_seen = true;
+    } else {
+        explorer_is_seen = false;
+    }
+    
+    this.showSectionsButton.setEnabled(explorer_is_seen);
+    this.showSpeciesButton.setEnabled(explorer_is_seen);
+}
+
+function editMenuCB(ev)
+{
+    var explorer_is_seen;
+    
+    if (this.entity_tree.isSeeable()) {
+        explorer_is_seen = true;
+    } else {
+        explorer_is_seen = false;
+    }
+
+    var tree = this.entity_tree;
+    var leaf = tree.getSelectedElement();
+
+    if (leaf && explorer_is_seen) {
+        if (this.isFavorite(leaf)) {
+            this.editMenuButtonAddToFav.setEnabled(false);
+            this.editMenuButtonRemFromFav.setEnabled(true);
+        } else {
+            this.editMenuButtonAddToFav.setEnabled(true);
+            this.editMenuButtonRemFromFav.setEnabled(false);
+        }
+    } else {
+        this.editMenuButtonAddToFav.setEnabled(false);
+        this.editMenuButtonRemFromFav.setEnabled(false);
+    }
+}
+
 function treeMenuCB(ev)
 {
@@ -397,15 +438,12 @@
                 if (this.isFavorite(leaf)) {
                     this.treeMenuButtonAddToFav.setEnabled(false);
-                    this.treeMenuButtonRemoveFromFav.setEnabled(true);
+                    this.treeMenuButtonRemFromFav.setEnabled(true);
                 } else {
                     this.treeMenuButtonAddToFav.setEnabled(true);
-                    this.treeMenuButtonRemoveFromFav.setEnabled(false);
+                    this.treeMenuButtonRemFromFav.setEnabled(false);
                 }
-
-                menu.setUserData("leaf", leaf);
             } else {
                 this.treeMenuButtonAddToFav.setEnabled(false);
-                this.treeMenuButtonRemoveFromFav.setEnabled(false);
-                menu.setUserData("leaf", null);
+                this.treeMenuButtonRemFromFav.setEnabled(false);
             }
             
@@ -453,10 +491,16 @@
 function addToFavCB(ev)
 {
-    var leaf = this.treeMenu.getUserData("leaf");
+    var tree = this.entity_tree;
+    var leaf = tree.getSelectedElement();
+
+    if (!leaf) {
+        return;
+    }
+
     leaf.setTextColor("red");
 
     // Add to the list of favorites
     var fav = new Array;
-    fav.entity = leaf.getUserData("entity");
+    fav.entity  = leaf.getUserData("entity");
     fav.species = leaf.getUserData("species");
     this.favorites.push(fav);
@@ -468,5 +512,10 @@
 function removeFromFavCB(ev)
 {
-    var leaf = this.treeMenu.getUserData("leaf");
+    var tree = this.entity_tree;
+    var leaf = tree.getSelectedElement();
+
+    if (!leaf) {
+        return;
+    }
     leaf.setTextColor("black");
 
@@ -767,12 +816,12 @@
         {
             var tree = this.entity_tree;
-            var e = tree.getSelectedElement();
-            
-            if (!e) {
+            var leaf = tree.getSelectedElement();
+            
+            if (!leaf) {
                 return;
             }
             
-            var entity = e.getUserData("entity");
-            var species = e.getUserData("species");
+            var entity  = leaf.getUserData("entity");
+            var species = leaf.getUserData("species");
             
             var name = this.getEntityFullName(entity, species);
@@ -861,5 +910,5 @@
 
                         leaf = new qx.ui.tree.TreeFile(entity.name, icon);
-                        leaf.addEventListener("click", clickEntityCB, this);
+                        leaf.addEventListener("changeSelected", clickEntityCB, this);
                         leaf.addEventListener("contextmenu", treeMenuCB, this);
                         leaf.setUserData("entity", entity);
@@ -876,5 +925,5 @@
                     leaf = new qx.ui.tree.TreeFile(entity.name,
                         "pf/image/all_small.png");
-                    leaf.addEventListener("click", clickEntityCB, this);
+                    leaf.addEventListener("changeSelected", clickEntityCB, this);
                     leaf.addEventListener("contextmenu", treeMenuCB, this);
                     leaf.setUserData("entity", entity);
@@ -1243,10 +1292,10 @@
                 border          : "inset-thin",
                 overflow        : "scroll",
-                height          : 530,
+                height          : 500,
                 width           : "100%",
                 paddingLeft     : 4,
                 paddingTop      : 4
             });
-            tree.addEventListener("contextmenu", treeMenuCB, this);
+            // tree.addEventListener("contextmenu", treeMenuCB, this);
             left_pane.add(tree);
             
@@ -1293,47 +1342,17 @@
             var button;
             
-            var subMenu1 = new qx.ui.menu.Menu;
-            button = new qx.ui.menu.CheckBox("Fundamental",
-                null, this.showFundamental);
-            button.addEventListener("execute", showFundamentalCB, this);
-            subMenu1.add(button);
-            button = new qx.ui.menu.CheckBox("Spectroscopy",
-                null, this.showSpectroscopy);
-            button.addEventListener("execute", showSpectroscopyCB, this);
-            subMenu1.add(button);
-            this.treeMenu.add(new qx.ui.menu.Button("Show sections",
-                null, null, subMenu1));
-            
-            this.treeMenu.add(new qx.ui.menu.Separator);
-
-            var subMenu2 = new qx.ui.menu.Menu;
-            button = new qx.ui.menu.CheckBox("Electrons",
-                null, this.showElectrons)
-            button.addEventListener("execute", showElectronsCB, this);
-            subMenu2.add(button);
-            button = new qx.ui.menu.CheckBox("Ions",
-                null, this.showIons)
-            button.addEventListener("execute", showIonsCB, this);
-            subMenu2.add(button);
-            button = new qx.ui.menu.CheckBox("Radiators",
-                null, this.showRadiators)
-            button.addEventListener("execute", showRadiatorsCB, this);
-            subMenu2.add(button);
-            this.treeMenu.add(new qx.ui.menu.Button("Show species",
-                null, null, subMenu2));
-            
-            this.treeMenu.add(new qx.ui.menu.Separator);
-
-            button = new qx.ui.menu.Button("Add to favorites");
+            button = new qx.ui.menu.Button("Add to Favorites",
+                "pf/image/favorite-add.png");
             button.addEventListener("execute", addToFavCB, this);
             this.treeMenu.add(button);
             this.treeMenuButtonAddToFav = button;
-            button = new qx.ui.menu.Button("Remove from favorites");
+            button = new qx.ui.menu.Button("Remove from Favorites",
+                "pf/image/favorite-delete.png");
             button.addEventListener("execute", removeFromFavCB, this);
             this.treeMenu.add(button);
-            this.treeMenuButtonRemoveFromFav = button;
+            this.treeMenuButtonRemFromFav = button;
             
             var doc = qx.ui.core.ClientDocument.getInstance();
-            doc.add(this.treeMenu, subMenu1, subMenu2);
+            doc.add(this.treeMenu);
 
 
@@ -1470,4 +1489,9 @@
         },
         
+        aboutCB : function(ev)
+        {
+            this.aboutWindow.open();
+        },
+        
         renderPlotTab : function()
         {
@@ -1475,5 +1499,135 @@
                 "pf/image/tab-plot.png");
         },
-        
+
+
+        buildMenu : function()
+        {
+            var menubar = this.menubar;
+            var doc = qx.ui.core.ClientDocument.getInstance();
+            
+            var submenu, btn;
+
+            var bg = "#efebec";
+            
+            submenu = new qx.ui.menu.Menu;
+            submenu.setBackgroundColor(bg);
+            doc.add(submenu);
+            btn = new qx.ui.menu.Button("Open...", "pf/image/open.png");
+            btn.addEventListener("execute", function (ev) {
+                alert("Not implemented yet")}, this);
+            submenu.add(btn);
+            btn = new qx.ui.menu.Button("Save...", "pf/image/save.png");
+            btn.addEventListener("execute", function (ev) {
+                alert("Not implemented yet")}, this);
+            submenu.add(btn);
+            submenu.add(new qx.ui.menu.Separator);
+            btn = new qx.ui.menu.Button("Exit", "pf/image/exit.png");
+            btn.addEventListener("execute", function (ev) {
+                window.close()}, this);
+            submenu.add(btn);
+                
+            btn = new qx.ui.menubar.Button("File", submenu);
+            btn.set({ paddingLeft : 7, paddingRight : 7 });
+            menubar.add(btn);
+
+
+            submenu = new qx.ui.menu.Menu;
+            submenu.setBackgroundColor(bg);
+            submenu.addEventListener("beforeAppear", editMenuCB, this);
+            doc.add(submenu);
+            btn = new qx.ui.menu.Button("Add to Favorites",
+                "pf/image/favorite-add.png");
+            btn.addEventListener("execute", addToFavCB, this);
+            this.editMenuButtonAddToFav = btn;
+            submenu.add(btn);
+            btn = new qx.ui.menu.Button("Remove from Favorites",
+                "pf/image/favorite-delete.png");
+            btn.addEventListener("execute", removeFromFavCB, this);
+            this.editMenuButtonRemFromFav = btn;
+            submenu.add(btn);
+            submenu.add(new qx.ui.menu.Separator);
+            btn = new qx.ui.menu.Button("Preferences",
+                "pf/image/preferences.png");
+            btn.addEventListener("execute", function (ev) {
+                alert("Not implemented yet")}, this);
+            submenu.add(btn);
+
+            btn = new qx.ui.menubar.Button("Edit", submenu);
+            btn.set({ paddingLeft : 7, paddingRight : 7 });
+            menubar.add(btn);
+
+
+            submenu = new qx.ui.menu.Menu;
+            submenu.setBackgroundColor(bg);
+            submenu.addEventListener("beforeAppear", viewMenuCB, this);
+
+            var subMenu1 = new qx.ui.menu.Menu;
+            subMenu1.setBackgroundColor(bg);
+            button = new qx.ui.menu.CheckBox("Fundamental",
+                null, this.showFundamental);
+            button.addEventListener("execute", showFundamentalCB, this);
+            subMenu1.add(button);
+            button = new qx.ui.menu.CheckBox("Spectroscopy",
+                null, this.showSpectroscopy);
+            button.addEventListener("execute", showSpectroscopyCB, this);
+            subMenu1.add(button);
+            this.showSectionsButton = new qx.ui.menu.Button("Show Sections",
+                null, null, subMenu1);
+            submenu.add(this.showSectionsButton);
+            
+            submenu.add(new qx.ui.menu.Separator);
+
+            var subMenu2 = new qx.ui.menu.Menu;
+            subMenu2.setBackgroundColor(bg);
+            button = new qx.ui.menu.CheckBox("Electrons",
+                null, this.showElectrons)
+            button.addEventListener("execute", showElectronsCB, this);
+            subMenu2.add(button);
+            button = new qx.ui.menu.CheckBox("Ions",
+                null, this.showIons)
+            button.addEventListener("execute", showIonsCB, this);
+            subMenu2.add(button);
+            button = new qx.ui.menu.CheckBox("Radiators",
+                null, this.showRadiators)
+            button.addEventListener("execute", showRadiatorsCB, this);
+            subMenu2.add(button);
+            this.showSpeciesButton = new qx.ui.menu.Button("Show Species",
+                null, null, subMenu2);
+            submenu.add(this.showSpeciesButton);
+            
+            doc.add(submenu, subMenu1, subMenu2);
+
+            btn = new qx.ui.menubar.Button("View", submenu);
+            btn.set({ paddingLeft : 7, paddingRight : 7 });
+            menubar.add(btn);
+
+
+            submenu = new qx.ui.menu.Menu;
+            submenu.setBackgroundColor(bg);
+            doc.add(submenu);
+            btn = new qx.ui.menu.Button("Help Contents",
+                "pf/image/help.png");
+            btn.addEventListener("execute", function (ev) {
+                alert("Not implemented yet")}, this);
+            submenu.add(btn);
+            btn = new qx.ui.menu.Button("NRL Plasma Formulary",
+                "pf/image/nrl.png");
+            btn.addEventListener("execute", function (ev) {
+                    var w = new qx.client.NativeWindow("http://wwwppd.nrl.navy.mil/nrlformulary/");
+                    w.setDimension(800, 600);
+                    w.open();
+                }, this);
+            submenu.add(btn);
+            submenu.add(new qx.ui.menu.Separator);
+            btn = new qx.ui.menu.Button("About Plasma Formulary",
+                "pf/image/about.png");
+            btn.addEventListener("execute", this.aboutCB, this);
+            submenu.add(btn);
+
+            btn = new qx.ui.menubar.Button("Help", submenu);
+            btn.set({ paddingLeft : 7, paddingRight : 7 });
+            menubar.add(btn);
+        },
+
         /**
          * TODOC
@@ -1491,4 +1645,6 @@
                 qx.core.Setting.get("pf.resourceUri"));
 
+            this.doc = qx.ui.core.ClientDocument.getInstance();
+            
             // Defaults
             
@@ -1518,18 +1674,11 @@
             this.bl_top.addToDocument();
 
-
-            // The toolbar
-            var tb = new qx.ui.toolbar.ToolBar;
-            this.bl_top.add(tb);
-
-            // ... and the buttons themselves
-
-            var sep = new qx.ui.toolbar.Separator;
-            tb.add(sep);
-
-            var btn = new qx.ui.toolbar.Button("About...");
-            tb.add(btn);
-            // btn.addEventListener("execute", this.aboutCB, this);
-
+            // The menubar
+            this.menubar = new qx.ui.menubar.MenuBar;
+            this.bl_top.add(this.menubar);
+            
+            // The menu items
+            this.buildMenu();
+            
             var tf1 = new qx.ui.pageview.tabview.TabView;
             tf1.set({ width : '100%', height : 'auto' });
@@ -1553,4 +1702,28 @@
             // The "Plot" tab
             this.renderPlotTab();
+
+            // "About..." dialog
+            var w = new qx.ui.window.Window("About Plasma Formulary",
+                "pf/image/about.png");
+            w.setSpace(200, "auto", 100, "auto");
+            w.setModal(true);
+            w.setShowMinimize(false);
+            w.setShowMaximize(false);
+            
+            str = 'Plasma Formulary Interactive.<br/>'         +
+                  '$Revision$.'                         +
+                  '<p>Written by Evgeny Stambulchik.</p>'      +
+                  '<p>Based on the Qooxdoo-' + qx.core.Version + 
+                  ' toolkit.</p>';
+
+            var a = new qx.ui.basic.Atom(str);
+            a.set({ top: 4, left: 4 });
+            w.add(a);
+
+            this.doc.add(w);
+            this.aboutWindow = w;
+            
+
+
         },
     
