Index: guiframe/data_panel.py
===================================================================
--- guiframe/data_panel.py	(revision 3b11d0dce08897bd4d999f379eb65f532226b5aa)
+++ guiframe/data_panel.py	(revision 2a62d5cba42d519269d94365fe861eb22a3d2f01)
@@ -11,4 +11,5 @@
 This module provides Graphic interface for the data_manager module.
 """
+import os
 import wx
 import sys
@@ -19,4 +20,26 @@
 from sans.guiframe.dataFitting import Data2D
 from sans.guiframe.panel_base import PanelBase
+from sans.guiframe.events import StatusEvent
+from DataLoader.loader import Loader
+
+try:
+    # Try to find a local config
+    import imp
+    path = os.getcwd()
+    if(os.path.isfile("%s/%s.py" % (path, 'local_config'))) or \
+        (os.path.isfile("%s/%s.pyc" % (path, 'local_config'))):
+        fObj, path, descr = imp.find_module('local_config', [path])
+        config = imp.load_module('local_config', fObj, path, descr)  
+    else:
+        # Try simply importing local_config
+        import local_config as config
+except:
+    # Didn't find local config, load the default 
+    import config
+ 
+extension_list = []
+if config.APPLICATION_STATE_EXTENSION is not None:
+    extension_list.append(config.APPLICATION_STATE_EXTENSION)
+EXTENSIONS = config.PLUGIN_STATE_EXTENSIONS + extension_list   
 
 PANEL_WIDTH = 180
@@ -72,4 +95,7 @@
         PanelBase.__init__(self)
         self.SetupScrolling()
+        self.loader = Loader()  
+        #Default location
+        self._default_save_location = None  
         self.all_data1d = True
         self.parent = parent
@@ -84,4 +110,6 @@
         self.do_layout()
         self.Bind(wx.EVT_SHOW, self.on_close_page)
+        self.enable_remove()
+        self.enable_import()
         
     def do_layout(self):
@@ -108,9 +136,9 @@
         self.sizer5 = wx.BoxSizer(wx.VERTICAL)
        
-        self.vbox.Add(self.sizer5, 0,wx.EXPAND|wx.ALL,10)
-        self.vbox.Add(self.sizer1, 0,wx.EXPAND|wx.ALL,0)
-        self.vbox.Add(self.sizer2, 0,wx.EXPAND|wx.ALL,10)
-        self.vbox.Add(self.sizer3, 0,wx.EXPAND|wx.ALL,10)
-        self.vbox.Add(self.sizer4, 0,wx.EXPAND|wx.ALL,10)
+        self.vbox.Add(self.sizer5, 0, wx.EXPAND|wx.ALL,1)
+        self.vbox.Add(self.sizer1, 0, wx.EXPAND|wx.ALL,0)
+        self.vbox.Add(self.sizer2, 0, wx.EXPAND|wx.ALL,1)
+        self.vbox.Add(self.sizer3, 0, wx.EXPAND|wx.ALL,1)
+        self.vbox.Add(self.sizer4, 0, wx.EXPAND|wx.ALL,5)
         
         self.SetSizer(self.vbox)
@@ -235,4 +263,10 @@
         Layout widgets related to buttons
         """
+        self.bt_add = wx.Button(self, wx.NewId(), "Load Data")
+        self.bt_add.SetToolTipString("Add data from the application")
+        wx.EVT_BUTTON(self, self.bt_add.GetId(), self._load_data)
+        self.bt_remove = wx.Button(self, wx.NewId(), "Remove Data")
+        self.bt_remove.SetToolTipString("Remove data from the application")
+        wx.EVT_BUTTON(self, self.bt_remove.GetId(), self.on_remove)
         self.bt_import = wx.Button(self, wx.NewId(), "Send To")
         self.bt_import.SetToolTipString("Send set of Data to active perspective")
@@ -250,8 +284,4 @@
         self.bt_freeze.SetToolTipString("To trigger freeze a theory")
         wx.EVT_BUTTON(self, self.bt_freeze.GetId(), self.on_freeze)
-        
-        self.bt_remove = wx.Button(self, wx.NewId(), "Remove Data")
-        self.bt_remove.SetToolTipString("Remove data from the application")
-        wx.EVT_BUTTON(self, self.bt_remove.GetId(), self.on_remove)
         
         self.tctrl_perspective = wx.StaticText(self, -1, 
@@ -274,6 +304,13 @@
         ix = 0
         iy = 0
+        self.sizer3.Add(self.bt_add,( iy, ix),(1,1),  
+                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5)
+        ix += 1          
+        self.sizer3.Add(self.bt_remove,( iy, ix),(1,1),  
+                             wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
+        ix = 0   
+        iy += 1
         self.sizer3.Add(self.bt_import,( iy, ix),(1,1),  
-                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5)
         ix += 1
         self.sizer3.Add(self.tctrl_perspective,(iy, ix),(1,1),
@@ -282,5 +319,5 @@
         iy += 1 
         self.sizer3.Add(self.bt_append_plot,( iy, ix),(1,1),  
-                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5)
         ix += 1
         self.sizer3.Add(self.cb_plotpanel,(iy, ix),(1,1),
@@ -289,20 +326,14 @@
         iy += 1 
         self.sizer3.Add(self.bt_plot,( iy, ix),(1,1),  
-                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5)
         ix = 0          
         iy += 1 
         self.sizer3.Add(self.bt_freeze,( iy, ix),(1,1),  
-                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix = 0          
-        iy += 1 
-        self.sizer3.Add(self.bt_remove,( iy, ix),(1,1),  
-                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        
-        
-     
+                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5)
+        
     def layout_batch(self):
         """
         """
-       
+        return
         self.rb_single_mode = wx.RadioButton(self, -1, 'Single Mode',
                                              style=wx.RB_GROUP)
@@ -386,4 +417,5 @@
         """
         if not list:
+            self.enable_remove()
             return
         # uncheck previous items
@@ -439,4 +471,5 @@
                                                           process.__str__())
             self.append_theory(state_id, theory_list)
+        self.enable_remove()
         
     def _uncheck_all(self):
@@ -598,4 +631,108 @@
                 del self.list_cb_theory[data_id]
               
+    def load_error(self, error=None):
+        """
+        Pop up an error message.
+        
+        :param error: details error message to be displayed
+        """
+        message = "The data file you selected could not be loaded.\n"
+        message += "Make sure the content of your file"
+        message += " is properly formatted.\n\n"
+        
+        if error is not None:
+            message += "When contacting the DANSE team, mention the"
+            message += " following:\n%s" % str(error)
+        dial = wx.MessageDialog(self.parent, message, 'Error Loading File',
+                                wx.OK | wx.ICON_EXCLAMATION)
+        dial.ShowModal()  
+        
+    def _load_data(self, event):
+        """
+        Load data
+        """
+        path = None
+        if self._default_save_location == None:
+            self._default_save_location = os.getcwd()
+        
+        cards = self.loader.get_wildcards()
+        wlist =  '|'.join(cards)
+        style = wx.OPEN|wx.FD_MULTIPLE
+        dlg = wx.FileDialog(self.parent, 
+                            "Choose a file", 
+                            self._default_save_location, "",
+                             wlist,
+                             style=style)
+        if dlg.ShowModal() == wx.ID_OK:
+            file_list = dlg.GetPaths()
+            if len(file_list) >= 0 and not(file_list[0]is None):
+                self._default_save_location = os.path.dirname(file_list[0])
+                path = self._default_save_location
+        dlg.Destroy()
+        
+        if path is None or not file_list or file_list[0] is None:
+            return
+        self.get_data(file_list)
+        
+    def get_data(self, path, format=None):
+        """
+        """
+        message = ""
+        log_msg = ''
+        output = {}
+        error_message = ""
+        for p_file in path:
+            basename  = os.path.basename(p_file)
+            root, extension = os.path.splitext(basename)
+            if extension.lower() in EXTENSIONS:
+                log_msg = "Data Loader cannot "
+                log_msg += "load: %s\n" % str(p_file)
+                log_msg += "Try File opening ...."
+                logging.info(log_msg)
+                continue
+        
+            try:
+                temp =  self.loader.load(p_file, format)
+                if temp.__class__.__name__ == "list":
+                    for item in temp:
+                        data = self.parent.create_gui_data(item, p_file)
+                        output[data.id] = data
+                else:
+                    data = self.parent.create_gui_data(temp, p_file)
+                    output[data.id] = data
+                message = "Loading Data..." + str(p_file) + "\n"
+                self.load_update(output=output, message=message)
+            except:
+                error_message = "Error while loading Data: %s\n" % str(p_file)
+                error_message += str(sys.exc_value) + "\n"
+                self.load_update(output=output, message=error_message)
+                
+        message = "Loading Data Complete! "
+        message += log_msg
+        self.load_complete(output=output, error_message=error_message,
+                       message=message, path=path)
+            
+    def load_update(self, output=None, message=""):
+        """
+        print update on the status bar
+        """
+        if message != "" and self.parent is not None:
+            wx.PostEvent(self.parent, StatusEvent(status=message,
+                                                  type="progress",
+                                                   info="warning"))
+            
+    def load_complete(self, output, message="", error_message="", path=None):
+        """
+         post message to  status bar and return list of data
+        """
+        if self.parent is not None:
+            wx.PostEvent(self.parent, StatusEvent(status=message,
+                                              info="warning",
+                                              type="stop"))
+        if error_message != "":
+            self.load_error(error_message)
+        if self.parent is not None:
+            self.parent.add_data(data_list=output)
+            
     def on_remove(self, event):
         """
@@ -635,4 +772,5 @@
         self.parent.remove_data(data_id=data_to_remove,
                                   theory_id=theory_to_remove)
+        self.enable_remove()
         
     def on_import(self, event=None):
@@ -690,5 +828,6 @@
         #perspective_font.SetWeight(wx.BOLD)
         self.tctrl_perspective.SetClientSize((80,20))#SetFont(perspective_font)
-     
+        self.enable_import()
+        
     def set_panel_on_focus(self, name):
         """
@@ -716,6 +855,25 @@
             panel = combo.GetClientData(selection)
             self.parent.on_set_plot_focus(panel)   
-
-    
+            
+    def enable_remove(self):
+        """
+        enable or disable remove button
+        """
+        n_t = self.tree_ctrl.GetCount()
+        n_t_t = self.tree_ctrl_theory.GetCount()
+        
+        if n_t + n_t_t <= 0:
+            self.bt_remove.Disable()
+        else:
+            self.bt_remove.Enable()
+            
+    def enable_import(self):
+        """
+        enable or disable send button
+        """
+        if self.tctrl_perspective.GetLabelText() == "No Active Application":
+            self.bt_import.Disable()
+        else:
+            self.bt_import.Enable()
 
 
Index: guiframe/gui_manager.py
===================================================================
--- guiframe/gui_manager.py	(revision 3554fd39b4ead27aaf1db0244d893a2b7cde858d)
+++ guiframe/gui_manager.py	(revision 2a62d5cba42d519269d94365fe861eb22a3d2f01)
@@ -1113,10 +1113,12 @@
             self._mgr.DetachPane(panel)
             panel.Destroy()
-            del self.panels[ID]
-            del self.plot_panels[ID]
+            if ID in self.panels.keys():
+                del self.panels[ID]
+            if ID in self.plot_panels.keys():
+                del self.plot_panels[ID]
             if self._data_panel is not None:
                 ind = self._data_panel.cb_plotpanel.FindString(str(caption))
                 if ind != wx.NOT_FOUND:
-                    self._data_panel.cb_plotpanel.Delete(ind)
+                   self._data_panel.cb_plotpanel.Delete(ind)
             self._mgr.Update()
       
@@ -2051,4 +2053,5 @@
         self.panel_on_focus = panel  
         self.set_panel_on_focus(None)
+        print " on_set_plot_focus"
          
     def _onDrawIdle(self, *args, **kwargs):
