627 def GetFilename(self): |
627 def GetFilename(self): |
628 if self.Project is not None: |
628 if self.Project is not None: |
629 if self.ProjectIsSaved(): |
629 if self.ProjectIsSaved(): |
630 return self.FileName |
630 return self.FileName |
631 else: |
631 else: |
632 return "~%s~"%self.FileName |
632 return "~%s~" % self.FileName |
633 return "" |
633 return "" |
634 |
634 |
635 # Change file path and save file name or create a default one if file path not defined |
635 # Change file path and save file name or create a default one if file path not defined |
636 def SetFilePath(self, filepath): |
636 def SetFilePath(self, filepath): |
637 self.FilePath = filepath |
637 self.FilePath = filepath |
638 if filepath == "": |
638 if filepath == "": |
639 self.LastNewIndex += 1 |
639 self.LastNewIndex += 1 |
640 self.FileName = _("Unnamed%d")%self.LastNewIndex |
640 self.FileName = _("Unnamed%d") % self.LastNewIndex |
641 else: |
641 else: |
642 self.FileName = os.path.splitext(os.path.basename(filepath))[0] |
642 self.FileName = os.path.splitext(os.path.basename(filepath))[0] |
643 |
643 |
644 # Change project properties |
644 # Change project properties |
645 def SetProjectProperties(self, name = None, properties = None, buffer = True): |
645 def SetProjectProperties(self, name = None, properties = None, buffer = True): |
2302 for resource in config.getresource(): |
2302 for resource in config.getresource(): |
2303 names[resource.getname().upper()] = True |
2303 names[resource.getname().upper()] = True |
2304 |
2304 |
2305 i = start_idx |
2305 i = start_idx |
2306 while name is None or names.get(name.upper(), False): |
2306 while name is None or names.get(name.upper(), False): |
2307 name = (format%i) |
2307 name = (format % i) |
2308 i += 1 |
2308 i += 1 |
2309 return name |
2309 return name |
2310 |
2310 |
2311 def PasteEditedElementInstances(self, tagname, text, new_pos, middle=False, debug=False): |
2311 def PasteEditedElementInstances(self, tagname, text, new_pos, middle=False, debug=False): |
2312 element = self.GetEditedElement(tagname, debug) |
2312 element = self.GetEditedElement(tagname, debug) |
2340 blocktype = instance.gettypeName() |
2340 blocktype = instance.gettypeName() |
2341 blocktype_infos = self.GetBlockType(blocktype) |
2341 blocktype_infos = self.GetBlockType(blocktype) |
2342 blockname = instance.getinstanceName() |
2342 blockname = instance.getinstanceName() |
2343 if blocktype_infos["type"] != "function" and blockname is not None: |
2343 if blocktype_infos["type"] != "function" and blockname is not None: |
2344 if element_type == "function": |
2344 if element_type == "function": |
2345 return _("FunctionBlock \"%s\" can't be pasted in a Function!!!")%blocktype |
2345 return _("FunctionBlock \"%s\" can't be pasted in a Function!!!") % blocktype |
2346 blockname = self.GenerateNewName(tagname, |
2346 blockname = self.GenerateNewName(tagname, |
2347 blockname, |
2347 blockname, |
2348 "%s%%d"%blocktype, |
2348 "%s%%d" % blocktype, |
2349 debug=debug) |
2349 debug=debug) |
2350 exclude[blockname] = True |
2350 exclude[blockname] = True |
2351 instance.setinstanceName(blockname) |
2351 instance.setinstanceName(blockname) |
2352 self.AddEditedElementPouVar(tagname, blocktype, blockname) |
2352 self.AddEditedElementPouVar(tagname, blocktype, blockname) |
2353 elif instance_type == "step": |
2353 elif instance_type == "step": |