Index: guiframe/data_panel.py
===================================================================
--- guiframe/data_panel.py	(revision 6db811e48346b01bffad193c2c44ef52e0ec045f)
+++ guiframe/data_panel.py	(revision 52725d67c5e2c977b51c94e8b602dbe1edccb6df)
@@ -18,4 +18,5 @@
 from sans.guiframe.dataFitting import Data1D
 from sans.guiframe.dataFitting import Data2D
+from sans.guiframe.panel_base import PanelBase
 
 PANEL_WIDTH = 200
@@ -31,5 +32,5 @@
         self.root = self.AddRoot("Available Data")
         
-class DataPanel(ScrolledPanel):
+class DataPanel(ScrolledPanel, PanelBase):
     """
     This panel displays data available in the application and widgets to 
@@ -49,4 +50,5 @@
         kwds['size']= size
         ScrolledPanel.__init__(self, parent=parent, *args, **kwds)
+        PanelBase.__init__(self)
         self.SetupScrolling()
       
Index: guiframe/gui_manager.py
===================================================================
--- guiframe/gui_manager.py	(revision 4753fc26255020c3536a5e7e6795cb5b16be90c9)
+++ guiframe/gui_manager.py	(revision 52725d67c5e2c977b51c94e8b602dbe1edccb6df)
@@ -130,5 +130,5 @@
         #self._check_update(None)
         # Register the close event so it calls our own method
-        wx.EVT_CLOSE(self, self._onClose)
+        wx.EVT_CLOSE(self, self.Close)
         # Register to status events
         self.Bind(EVT_STATUS, self._on_status_event)
@@ -463,7 +463,7 @@
                     id = wx.NewId()
                     m_name, m_hint, m_handler = item
-                    self._filemenu.Append(id, m_name, m_hint)
+                    self._file_menu.Append(id, m_name, m_hint)
                     wx.EVT_MENU(self, id, m_handler)
-                self._filemenu.AppendSeparator()
+                self._file_menu.AppendSeparator()
                 
     def _setup_menus(self):
@@ -647,16 +647,22 @@
         """
          # File menu
-        self._filemenu = wx.Menu()
+        self._file_menu = wx.Menu()
         # some menu of plugin to be seen under file menu
         self._populate_file_menu()
         id = wx.NewId()
-        self._filemenu.Append(id, '&Save state into File',
-                             'Save project as a SansView (svs) file')
-        wx.EVT_MENU(self, id, self._on_save)
+        self._file_menu.Append(id, '&Save Application',
+                             'Save state of the current active application')
+        wx.EVT_MENU(self, id, self._on_save_application)
         id = wx.NewId()
-        self._filemenu.Append(id, '&Quit', 'Exit') 
+        self._file_menu.Append(id, '&Save Project',
+                             'Save the state of the whole application')
+        wx.EVT_MENU(self, id, self._on_save_project)
+        self._file_menu.AppendSeparator()
+        
+        id = wx.NewId()
+        self._file_menu.Append(id, '&Quit', 'Exit') 
         wx.EVT_MENU(self, id, self.Close)
         # Add sub menus
-        self._menubar.Append(self._filemenu, '&File')
+        self._menubar.Append(self._file_menu, '&File')
         
     def _add_menu_data(self):
@@ -776,7 +782,5 @@
         if path is None:
             return
-        
-        from data_loader import plot_data
-        from sans.perspectives import invariant
+
         if path and os.path.isfile(path):
             basename  = os.path.basename(path)
@@ -797,15 +801,16 @@
             self.on_close_welcome_panel()
             
-    def _on_save(self, event):
-        """
-        Save state into a file
-        """
-        # Ask the user the location of the file to write to.
-        
+    def _on_save_application(self, event):
+        """
+        save the state of the current active application
+        """
         ## Default file location for save
         self._default_save_location = os.getcwd()
+        if self._current_perspective is  None:
+            return
+        reader, ext = self._current_perspective.get_extensions()
         path = None
         dlg = wx.FileDialog(self, "Choose a file",
-                            self._default_save_location, "", "*.svs", wx.SAVE)
+                            self._default_save_location, "", ext, wx.SAVE)
         if dlg.ShowModal() == wx.ID_OK:
             path = dlg.GetPath()
@@ -818,43 +823,51 @@
         # default cansas xml doc
         doc = None
-        for item in self.panels:
-            try:
-                if self.panels[item].window_name == 'Invariant':
-                    data = self.panels[item]._data
-                    if data != None:
-                        state = self.panels[item].state
-                        manager = self.panels[item]._manager
-                        new_doc = manager.state_reader.write_toXML(data, state)
-                        if hasattr(doc, "firstChild"):
-                            child = new_doc.firstChild.firstChild
-                            doc.firstChild.appendChild(child)  
-                        else:
-                            doc = new_doc 
-                elif self.panels[item].window_name == 'pr_control':
-                    data = self.panels[item].manager.current_plottable
-                    if data != None:
-                        state = self.panels[item].get_state()
-                        manager = self.panels[item].manager
-                        new_doc = manager.state_reader.write_toXML(data, state)
-                        if hasattr(doc, "firstChild"):
-                            child = new_doc.firstChild.firstChild
-                            doc.firstChild.appendChild(child)  
-                        else:
-                            doc = new_doc 
-                elif self.panels[item].window_name == 'Fit panel':
-                    for index in range(self.panels[item].GetPageCount()):
-                        selected_page = self.panels[item].GetPage(index) 
-                        if hasattr(selected_page,"get_data"):
-                            data = selected_page.get_data()
-                            state = selected_page.state
-                            reader = selected_page.manager.state_reader
-                            new_doc = reader.write_toXML(data, state)
-                            if doc != None and hasattr(doc, "firstChild"):
-                                child = new_doc.firstChild.firstChild
-                                doc.firstChild.appendChild(child)
-                            else:
-                                doc = new_doc
-            except: 
-                pass
+        for panel in self._current_perspective.get_perspective():
+            doc = on_save_helper(doc, reader, panel, path)
+            
+    def _on_save_project(self, event):
+        """
+        save the state of the current active application
+        """
+        ## Default file location for save
+        self._default_save_location = os.getcwd()
+        if self._current_perspective is  None:
+            return
+        reader, ext = self._current_perspective.get_extensions()
+        path = None
+        dlg = wx.FileDialog(self, "Choose a file",
+                            self._default_save_location, "", '.svs', wx.SAVE)
+        if dlg.ShowModal() == wx.ID_OK:
+            path = dlg.GetPath()
+            self._default_save_location = os.path.dirname(path)
+        else:
+            return None
+        dlg.Destroy()
+        if path is None:
+            return
+        # default cansas xml doc
+        doc = None
+        for panel in self.panels.values():
+            doc = self.on_save_helper(doc, reader, panel, path)
+        
+            
+    def on_save_helper(self, doc, reader, panel, path):
+        """
+        Save state into a file
+        """
+        try:
+            data = panel.get_data()
+            state = panel.get_state()
+            if reader is not None:
+                if data is not None:
+                    new_doc = reader.write_toXML(data, state)
+                    if hasattr(doc, "firstChild"):
+                        child = new_doc.firstChild.firstChild
+                        doc.firstChild.appendChild(child)  
+                    else:
+                        doc = new_doc 
+        except: 
+            raise
+            #pass
         # Write the XML document
         if doc != None:
@@ -863,14 +876,9 @@
             fd.close()
         else:
+            raise
             #print "Nothing to save..."
-            raise RuntimeError, "%s is not a SansView (.svs) file..." % path
-
-    def _onClose(self, event):
-        """
-        Store info to retrieve in xml before closing the application
-        """
-        wx.Exit()
-        sys.exit()
-                 
+            #raise RuntimeError, "%s is not a SansView (.svs) file..." % path
+        return doc
+
     def quit_guiframe(self):
         """
@@ -890,7 +898,6 @@
         Quit the application
         """
-        flag = self.quit_guiframe()
-        if flag:
-            wx.Frame.Close(self)
+        #flag = self.quit_guiframe()
+        if True:
             wx.Exit()
             sys.exit()
@@ -1015,21 +1022,4 @@
         self._mgr.Update()
         
-    def choose_file(self, path=None):
-        """ 
-        Functionality that belongs elsewhere
-        Should add a hook to specify the preferred file type/extension.
-        """
-        #TODO: clean this up
-        from .data_loader import choose_data_file
-        # Choose a file path
-        if path == None:
-            path = choose_data_file(self, self._default_save_location)
-        if not path == None:
-            try:
-                self._default_save_location = os.path.dirname(path)
-            except:
-                pass
-        return path
-    
     def show_data_panel(self, event=None):
         """
@@ -1041,5 +1031,5 @@
         self._mgr.Update()
   
-    def add_data(self, data_list):
+    def add_data(self, data_list, flag=False):
         """
         receive a list of data . store them its data manager if possible
@@ -1052,4 +1042,8 @@
             avalaible_data = self._data_manager.get_all_data()
             
+        if flag:
+            #reading a state file
+            for plug in self.plugins:
+                plug.on_set_state_helper(event=None)
         style = self.__gui_style & GUIFRAME.MANAGER_ON
         if style == GUIFRAME.MANAGER_ON:
Index: guiframe/local_perspectives/data_loader/data_loader.py
===================================================================
--- guiframe/local_perspectives/data_loader/data_loader.py	(revision 52b8b74ee4a07398ef3f87d25aa332dfba2e9656)
+++ guiframe/local_perspectives/data_loader/data_loader.py	(revision 52725d67c5e2c977b51c94e8b602dbe1edccb6df)
@@ -17,12 +17,9 @@
 from sans.guiframe.utils import parse_name
 
-STATE_FILE_EXT = ['P(r) files (*.prv)|*.prv',
-                  'P(r) files (*.sav)|*.sav',
-                  'P(r) files (*.svs)|*.svs',
+STATE_FILE_EXT = ['SansView files (*.svs)|*.svs',
+                  'P(r) files (*.prv)|*.prv',
                   'Fitting files (*.fitv)|*.fitv',
-                  'Fitting files (*.svs)|*.svs',
-                  'Invariant files (*.inv)|*.inv',
-                  'Invariant files (*.svs)|*.svs']
-EXTENSIONS = ['.svs', '.prv', '.inv', '.fitv']
+                  'Invariant files (*.inv)|*.inv']
+EXTENSIONS = ['.svs', '.prv','.fitv', '.inv']
 
 class Plugin(PluginBase):
@@ -195,8 +192,10 @@
                 temp =  self.loader.load(p_file)
                 if temp.__class__.__name__ == "list":
+                    print "list", temp
                     for item in temp:
                         data = self.create_data(item, p_file)
                         output.append(data)
                 else:
+                    print "list", temp
                     data = self.create_data(temp, p_file)
                     output.append(data)
@@ -204,4 +203,5 @@
                 self.load_update(output=output, message=message)
             except:
+                raise
                 error_message = "Error while loading: %s\n" % str(p_file)
                 error_message += str(sys.exc_value) + "\n"
@@ -211,5 +211,5 @@
         message += log_msg
         self.load_complete(output=output, error_message=error_message,
-                       message=message, path=path)
+                       message=message, path=path, flag=flag)
             
    
@@ -240,5 +240,6 @@
                                                    info="warning"))
         
-    def load_complete(self, output, message="", error_message="", path=None):
+    def load_complete(self, output, message="", error_message="", 
+                      path=None, flag=True):
         """
          post message to  status bar and return list of data
@@ -249,5 +250,5 @@
         if error_message != "":
             self.load_error(error_message)
-        self.parent.add_data(output)
+        self.parent.add_data(output, flag=flag)
         
     def create_data(self, data, path):
Index: guiframe/panel_base.py
===================================================================
--- guiframe/panel_base.py	(revision 691643c46c33929157442bf0cf1b7127d59da6d0)
+++ guiframe/panel_base.py	(revision 52725d67c5e2c977b51c94e8b602dbe1edccb6df)
@@ -28,4 +28,7 @@
         Initialize some flag that Viewerframe used
         """
+        #panel manager
+        self._manager = None
+        
         self._print_flag = False
         self._undo_flag = False
@@ -229,3 +232,23 @@
         """
         
-   
+    def get_data(self):
+        """
+        return list of current data
+        """
+        return
+    
+    def get_state(self):
+        """
+         return the current state
+        """
+        return
+
+    def set_manager(self, manager):
+        """
+        """
+        self._manager = manager 
+        
+    def get_manager(self):
+        """
+        """
+        return self._manager
Index: guiframe/plugin_base.py
===================================================================
--- guiframe/plugin_base.py	(revision bf4402c376f8ead3899ab313483ea9aad7c66042)
+++ guiframe/plugin_base.py	(revision 52725d67c5e2c977b51c94e8b602dbe1edccb6df)
@@ -41,9 +41,17 @@
         ## Reference to the parent window. Filled by get_panels() below.
         self.parent = None
-        
+        #plugin state reader
+        self.state_reader = None 
+        self._extensions = ''
         ## List of panels that you would like to open in AUI windows
         #  for your plug-in. This defines your plug-in "perspective"
         self.perspective = []
         
+    def get_extensions(self):
+        """
+        return state reader and its extensions
+        """
+        return self.state_reader, self._extensions
+    
     def can_load_data(self):
         """
@@ -196,2 +204,7 @@
         receive a list of data and use it in the current perspective
         """
+    def on_set_state_helper(self, event):
+        """
+        update state
+        """
+    
