Index: guiframe/data_manager.py
===================================================================
--- guiframe/data_manager.py	(revision 584c4c42de7f561146b2dab9184b786cc646381a)
+++ guiframe/data_manager.py	(revision 213892bc3e00d15d4ece8ef19460ff84e84aa551)
@@ -47,6 +47,5 @@
             self._selected_data[data.id] = data_state
             self.stored_data[data.id] = data_state
-        print "datalist", self._selected_data    
-        
+      
     def set_auto_plot(self, flag=False):
         """
@@ -78,4 +77,16 @@
         return self._selected_data
     
+    def append_theory(self, data_id, theory):
+        """
+        """
+        print "append theory", self.stored_data, data_id
+        if data_id in self.stored_data:
+            data_state = self.stored_data[data_id]
+            data_state.set_theory(theory)
+            
+    def delete_data(self, data_id, theory_id, delete_all):
+        """
+        """
+        #for id in 
     def delete_by_id(self, id_list=None):
         """
Index: guiframe/data_panel.py
===================================================================
--- guiframe/data_panel.py	(revision 584c4c42de7f561146b2dab9184b786cc646381a)
+++ guiframe/data_panel.py	(revision 213892bc3e00d15d4ece8ef19460ff84e84aa551)
@@ -192,6 +192,6 @@
         
         self.bt_append_plot = wx.Button(self, wx.NewId(), "Append Plot To")
-        self.bt_import.SetToolTipString("Plot the selected data in the active panel")
-        #wx.EVT_BUTTON(self, self.bt_import.GetId(), self.on_append_plot)
+        self.bt_append_plot.SetToolTipString("Plot the selected data in the active panel")
+        wx.EVT_BUTTON(self, self.bt_append_plot.GetId(), self.on_append_plot)
         
         self.bt_plot = wx.Button(self, wx.NewId(), "New Plot")
@@ -205,6 +205,6 @@
         self.tctrl_perspective = wx.StaticText(self, -1, 'No Active Application')
         self.tctrl_perspective.SetToolTipString("Active Application")
-        self.tctrl_plotpanel = wx.StaticText(self, -1, 'Plot panel on focus')
-        self.tctrl_plotpanel.SetToolTipString("Active Plotting Panel")
+        self.tctrl_plotpanel = wx.StaticText(self, -1, 'No Plot panel on focus')
+        self.tctrl_plotpanel.SetToolTipString("Active Plot Panel")
         #self.sizer3.AddMany([(self.bt_import,0, wx.ALL,5),
         #                     (self.bt_append_plot,0, wx.ALL,5),
@@ -296,5 +296,4 @@
         
         """
-        print "list", list
         if not list:
             return
@@ -366,9 +365,10 @@
         for item in self.list_cb_data:
             if item.IsChecked():
+                
                data_to_plot.append(self.tree_ctrl.GetItemPyData(item))
         theory_to_plot = []
         for item in self.list_cb_theory:
             if item.IsChecked():
-               theory_to_plot.append(self.tree_ctrl.GetItemPyData(item))
+                theory_to_plot.append(self.tree_ctrl.GetItemPyData(item))
         return data_to_plot, theory_to_plot
     
@@ -379,10 +379,14 @@
                 self.tree_ctrl.GetItemText(item) in data_to_remove:
                 self.tree_ctrl.Delete(item)
-        for i in self.list_cb_theory:
+        for item in self.list_cb_theory:
             if item.IsChecked()and \
                 self.tree_ctrl.GetItemText(item) in theory_to_remove:
                 self.tree_ctrl.Delete(item)
-        self.manager.delete_data(data_name=data_to_remove,
-                                  theory_name=theory_to_remove)
+        delete_all = False
+        if data_to_remove:
+            delete_all = True
+        self.parent.delete_data(data_id=data_to_remove,
+                                  theory_id=theory_to_remove,
+                                  delete_all=delete_all)
         
     def on_import(self, event=None):
@@ -391,5 +395,11 @@
         """
         self.post_helper(plot=False)
-        
+       
+    def on_append_plot(self, event=None):
+        """
+        append plot to plot panel on focus
+        """
+        self.post_helper(plot=True, append=True)
+   
     def on_plot(self, event=None):
         """
@@ -410,5 +420,5 @@
         self.tctrl_plotpanel.SetLabel(str(name))
         
-    def post_helper(self, plot=False):
+    def post_helper(self, plot=False, append=False):
         """
         """
@@ -416,5 +426,6 @@
       
         if self.parent is not None:
-            self.parent.get_data_from_panel(data_id=data_to_plot, plot=plot)
+            self.parent.get_data_from_panel(data_id=data_to_plot, plot=plot,
+                                            append=append)
 
 
Index: guiframe/gui_manager.py
===================================================================
--- guiframe/gui_manager.py	(revision 584c4c42de7f561146b2dab9184b786cc646381a)
+++ guiframe/gui_manager.py	(revision 213892bc3e00d15d4ece8ef19460ff84e84aa551)
@@ -53,4 +53,5 @@
 
 
+
 class ViewerFrame(wx.Frame):
     """
@@ -91,9 +92,4 @@
         self.app_manager = None
         self._mgr = None
-        #data manager
-        from data_manager import DataManager
-        self._data_manager = DataManager()
-        self._data_panel = DataPanel(parent=self)
-        
         #add current perpsective
         self._current_perspective = None
@@ -128,4 +124,10 @@
         #panel on focus
         self.panel_on_focus = None
+         #data manager
+        from data_manager import DataManager
+        self._data_manager = DataManager()
+        self._data_panel = DataPanel(parent=self)
+        if self.panel_on_focus is not None:
+            self._data_panel.set_panel_on_focus(self.panel_on_focus.window_name)
         # Check for update
         #self._check_update(None)
@@ -141,6 +143,9 @@
         Store reference to the last panel on focus
         """
+        print "set_panel_on_focus", event.panel
         self.panel_on_focus = event.panel
-        
+        if self.panel_on_focus is not None and self._data_panel is not None:
+            self._data_panel.set_panel_on_focus(self.panel_on_focus.window_name)
+            
     def build_gui(self):
         """
@@ -434,5 +439,5 @@
                               BestSize(wx.Size(PLOPANEL_WIDTH, PLOPANEL_HEIGTH)))
             self._popup_fixed_panel(p)
-            
+    
         elif style2 in GUIFRAME.FLOATING_PANEL:
             self._mgr.AddPane(p, wx.aui.AuiPaneInfo().
@@ -673,4 +678,6 @@
             if plug.can_load_data():
                 plug.load_data(event)
+        self.show_data_panel(event=None)
+        print "_load_data"
                 
     def _load_folder(self, event):
@@ -682,4 +689,5 @@
             if plug.can_load_data():
                 plug.load_folder(event)
+        self.show_data_panel(event=None)
                 
     def _on_status_event(self, evt):
@@ -1008,12 +1016,12 @@
         return path
     
-    def show_data_panel(self, event):
+    def show_data_panel(self, event=None):
         """
         show the data panel
         """
         pane = self._mgr.GetPane(self.panels["data_panel"].window_name)
-        if not pane.IsShown():
-            pane.Show(True)
-            self._mgr.Update()
+        #if not pane.IsShown():
+        pane.Show(True)
+        self._mgr.Update()
   
     def add_data(self, data_list):
@@ -1041,5 +1049,5 @@
                 self.set_data(data_list)
                 
-    def get_data_from_panel(self, data_id, plot=False):
+    def get_data_from_panel(self, data_id, plot=False,append=False):
         """
         receive a list of data key retreive the data from data manager and set 
@@ -1051,5 +1059,5 @@
             data_list.append(data_state.data)
         if plot:
-            self.plot_data(data_list)
+            self.plot_data(data_list, append=append)
         else:
             #sent data to active application
@@ -1071,13 +1079,47 @@
             logging.info(msg)
             
-    def plot_data(self, data_list):
+    def plot_data(self, data_list, append=False):
         """
         send a list of data to plot
         """
+        if not data_list:
+            message = "Please check data to plot or append"
+            wx.PostEvent(self, StatusEvent(status=message, info='warning'))
+            return 
         for new_plot in data_list:
-            
+            if append:
+                if self.panel_on_focus is None:
+                    message = "cannot append plot. No plot panel on focus!"
+                    message += "please click on any available plot to set focus"
+                    wx.PostEvent(self, StatusEvent(status=message, 
+                                                   info='warning'))
+                    return 
+                else:
+                    if self.enable_add_data(new_plot):
+                        new_plot.group_id = self.panel_on_focus.group_id
             wx.PostEvent(self, NewPlotEvent(plot=new_plot,
                                                   title=str(new_plot.title)))
             
+    def add_theory(self, data_id, theory):
+        """
+        """
+        self._data_manager.append_theory(data_id, theory)
+        style = self.__gui_style & GUIFRAME.MANAGER_ON
+        if style == GUIFRAME.MANAGER_ON:
+            if self._data_panel is not None:
+                data_state = self._data_manager.get_by_id([data_id])
+                self._data_panel.load_data_list(data_state)
+                
+    def delete_data(self, data_id, theory_id=None, delete_all=True):
+        """
+        Delete data state if data_id is provide
+        delete theory created with data of id data_id if theory_id is provide
+        if delete all true: delete the all state
+        else delete theory
+        """
+        self._data_manager.delete_data(data_id=data_id, 
+                                       theory_id=theory_id, 
+                                       delete_all=delete_all)
+        
     def set_current_perspective(self, perspective):
         """
@@ -1091,5 +1133,5 @@
             self._data_panel.set_active_perspective(name)
            
-    def set_plotpanel_floating(self, event):
+    def set_plotpanel_floating(self, event=None):
         """
         make the plot panel floatable
@@ -1102,5 +1144,5 @@
                     self._popup_floating_panel(p)
         
-    def set_plotpanel_fixed(self, event):
+    def set_plotpanel_fixed(self, event=None):
         """
         make the plot panel fixed
@@ -1140,4 +1182,25 @@
             self._mgr.GetPane(p.window_name).Show(flag)
             self._mgr.Update()
+            
+    def enable_add_data(self, new_plot):
+        """
+        Enable append data on a plot panel
+        """
+        is_theory = len(self.panel_on_focus.plots) <= 1 and \
+            self.panel_on_focus.plots.values()[0].__class__.__name__ == "Theory1D"
+            
+        is_data2d = hasattr(new_plot, 'data')
+        is_data1d = self.panel_on_focus.__class__.__name__ == "ModelPanel1D"\
+            and self.panel_on_focus.group_id is not None
+        has_meta_data = hasattr(new_plot, 'meta_data')
+        
+        #disable_add_data if the data is being recovered from  a saved state file.
+        is_state_data = False
+        if has_meta_data:
+            if 'invstate' in new_plot.meta_data: is_state_data = True
+            if  'prstate' in new_plot.meta_data: is_state_data = True
+            if  'fitstate' in new_plot.meta_data: is_state_data = True
+    
+        return is_data1d and not is_data2d and not is_theory and not is_state_data
         
 class DefaultPanel(wx.Panel):
