def profile_open(self, evt): """Used open file dialog box to allow user to select a file, then load it into the profile class. """ if self.profile.connState == "altered" or len([d.document for d in self.documentEditorControl.documentsOpen.values()\ if d.document.state == "altered"]) > 0: dlg = SaveOrDiscard(wx.GetApp().GetTopWindow()) dlg.ShowModal() if dlg.result == "save": self.save_all_docs() self.profile.save_connections() elif dlg.result == "cancel": dlg.Destroy() return dlg.Destroy() #close all tabs self.documentEditorControl.close_all_tabs() self.profile = profile.Profile() #reset profile to zero self.documentEditorControl.profile = self.profile datahandler.ConnectionManager.dataConnections = dict() datahandler.DataHandler.metaData = dict() datahandler.DataHandler.dataObjects = dict() dlg = wx.FileDialog(wx.GetApp().GetTopWindow(), "Open Project", os.getcwd(), "", "*.pro", wx.OPEN) dlg.ShowModal() path = dlg.GetPath() dlg.Destroy() if path != '': if path[-4:] != ".pro": self.profile._fileName = path + ".pro" else: self.profile._fileName = path self.profilePanelControl.refresh(self.profile) self.profile.open_profile() #load connections datahandler.load_data_connections(self.profile.connections) self.dataPanelControl.refresh(self.profile)
def add_data_source(self, evt): """Runs a select data source wizard and handles any errors raised when adding it to the current profile""" if self.profile._fileName == '': dlg = wx.FileDialog(wx.GetApp().GetTopWindow(), "Name your project file", os.getcwd(), "", "*.pro", wx.SAVE) if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath() dlg.Destroy() if path[-4:] != ".pro": self.profile._fileName = path + ".pro" else: self.profile._fileName = path try: self.profilePanelControl.refresh(self.profile) self.profile.open_profile() #load connections datahandler.load_data_connections(self.profile.connections) self.dataPanelControl.refresh(self.profile) except IOError: pass else: return wizards.WizardNewDataSource(self.frame, self.profile)