# HG changeset patch # User Surkov Sergey # Date 1499166042 -10800 # Node ID ae58d214997c65960901e5a4edd6ae8a747c591d # Parent a0682ec03f1fb9160b04b40fd994b64f79933fae# Parent c1987ef148e4bd920e3f5c38c849632acb0f16a1 Backout commit 92537ed because of writing localized string in node *.xml file diff -r c1987ef148e4 -r ae58d214997c BeremizIDE.py --- a/BeremizIDE.py Tue Jul 04 13:46:48 2017 +0300 +++ b/BeremizIDE.py Tue Jul 04 14:00:42 2017 +0300 @@ -849,6 +849,7 @@ if self.EnableDebug: self.DebugVariablePanel.SetDataProducer(self.CTR) self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) + IDEFrame.OnAddNewProject(self, event) else: self.ResetView() self.ShowErrorMessage(result) diff -r c1987ef148e4 -r ae58d214997c IDEFrame.py --- a/IDEFrame.py Tue Jul 04 13:46:48 2017 +0300 +++ b/IDEFrame.py Tue Jul 04 14:00:42 2017 +0300 @@ -2047,7 +2047,7 @@ self.TabsOpened.DeletePage(idx) else: editor.SubscribeAllDataConsumers() - elif editor.IsDebugging(): + elif editor.IsDebugging() and hasattr(editor, 'SubscribeAllDataConsumers'): editor.SubscribeAllDataConsumers() self.DebugVariablePanel.SubscribeAllDataConsumers() @@ -2277,25 +2277,36 @@ # Add Project Elements Functions #------------------------------------------------------------------------------- + def OnAddNewProject(self, event): + # Asks user to create main program after creating new project + AddProgramDialog = self.GenerateAddPouFunction('program', True) + # Checks that user created main program + if AddProgramDialog(event): + self.Controler.SetProjectDefaultConfiguration() + def OnAddDataTypeMenu(self, event): tagname = self.Controler.ProjectAddDataType() if tagname is not None: self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE) self.EditProjectElement(ITEM_DATATYPE, tagname) - def GenerateAddPouFunction(self, pou_type): + def GenerateAddPouFunction(self, pou_type, type_readonly = False): def OnAddPouMenu(event): - dialog = PouDialog(self, pou_type) + dialog = PouDialog(self, pou_type, type_readonly) dialog.SetPouNames(self.Controler.GetProjectPouNames()) dialog.SetPouElementNames(self.Controler.GetProjectPouVariableNames()) dialog.SetValues({"pouName": self.Controler.GenerateNewName(None, None, "%s%%d" % pou_type)}) + pou_created = False if dialog.ShowModal() == wx.ID_OK: values = dialog.GetValues() tagname = self.Controler.ProjectAddPou(values["pouName"], values["pouType"], values["language"]) if tagname is not None: self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, LIBRARYTREE) self.EditProjectElement(ITEM_POU, tagname) + dialog.Destroy() + pou_created = True dialog.Destroy() + return pou_created return OnAddPouMenu def GenerateAddTransitionFunction(self, pou_name): diff -r c1987ef148e4 -r ae58d214997c ProjectController.py --- a/ProjectController.py Tue Jul 04 13:46:48 2017 +0300 +++ b/ProjectController.py Tue Jul 04 14:00:42 2017 +0300 @@ -393,6 +393,18 @@ self.ProjectAddConfiguration(config_name) self.ProjectAddConfigurationResource(config_name, res_name) + def SetProjectDefaultConfiguration(self): + # Sets default task and instance for new project + config = self.Project.getconfiguration(self.GetProjectMainConfigurationName()) + resource = config.getresource()[0].getname() + config = config.getname() + resource_tagname = self.ComputeConfigurationResourceName(config, resource) + def_task = [ + {'Priority': '0', 'Single': '', 'Interval': 'T#20ms', 'Name': 'task0', 'Triggering': 'Cyclic'}] + def_instance = [ + {'Task': def_task[0].get('Name'), 'Type': self.GetProjectPouNames()[0], 'Name': 'instance0'}] + self.SetEditedResourceInfos(resource_tagname, def_task, def_instance) + def NewProject(self, ProjectPath, BuildPath=None): """ Create a new project in an empty folder diff -r c1987ef148e4 -r ae58d214997c dialogs/PouDialog.py --- a/dialogs/PouDialog.py Tue Jul 04 13:46:48 2017 +0300 +++ b/dialogs/PouDialog.py Tue Jul 04 14:00:42 2017 +0300 @@ -41,7 +41,7 @@ POU_LANGUAGES = GetPouLanguages() POU_LANGUAGES_DICT = dict([(_(language), language) for language in POU_LANGUAGES]) - def __init__(self, parent, pou_type = None): + def __init__(self, parent, pou_type=None, type_readonly=False): wx.Dialog.__init__(self, id=-1, parent=parent, name='PouDialog', title=_('Create a new POU'), style=wx.DEFAULT_DIALOG_STYLE) @@ -85,7 +85,8 @@ self.SetSizer(main_sizer) for option in GetPouTypes(): - self.PouType.Append(_(option)) + if not type_readonly or _(option) == _(pou_type): + self.PouType.Append(_(option)) if pou_type is not None: self.PouType.SetStringSelection(_(pou_type)) self.RefreshLanguage() diff -r c1987ef148e4 -r ae58d214997c editors/Viewer.py --- a/editors/Viewer.py Tue Jul 04 13:46:48 2017 +0300 +++ b/editors/Viewer.py Tue Jul 04 14:00:42 2017 +0300 @@ -1606,6 +1606,8 @@ menu.Enable(new_id, True) else: menu.Enable(new_id, False) + if self.Editor.HasCapture(): + self.Editor.ReleaseMouse() self.Editor.PopupMenu(menu) menu.Destroy() diff -r c1987ef148e4 -r ae58d214997c targets/toolchain_makefile.py --- a/targets/toolchain_makefile.py Tue Jul 04 13:46:48 2017 +0300 +++ b/targets/toolchain_makefile.py Tue Jul 04 14:00:42 2017 +0300 @@ -110,7 +110,7 @@ } # clean sequence of multiple whitespaces - cmd = re.sub(r"[ ]+", " ", target.getCommand()) + cmd = re.sub(r"[ ]+", " ", target.getCommand().strip()) command = [ token % beremizcommand for token in cmd.split(' ')]