def mouseReleaseEvent(self, event): ''' Opens the new editor, if the user clicked on the included file and sets the default cursor. ''' if self.isReadOnly(): event.accept() return if event.modifiers() == Qt.ControlModifier or event.modifiers() == Qt.ShiftModifier: cursor = self.cursorForPosition(event.pos()) try: textblock = self._strip_bad_parts(cursor.block().text(), cursor.positionInBlock()) for inc_file in find_included_files(textblock, False, False, search_in_ext=[]): aval = inc_file.raw_inc_path aitems = aval.split("'") for search_for in aitems: if not search_for: continue try: rospy.logdebug("try to interpret: %s" % search_for) args_in_name = get_arg_names(search_for) resolved_args = {} # if found arg in the name, try to detect values if args_in_name: rospy.logdebug(" args %s in filename found, try to resolve..." % args_in_name) resolved_args = self.parent.graph_view.get_include_args(args_in_name, search_for, self.filename) if resolved_args: params = {} self._internal_args # create parameter dialog for key, val in resolved_args.items(): values = list(val) # add args defined in current file if key in self._internal_args and self._internal_args[key] not in values: values.append(self._internal_args[key]) params[key] = {':type': 'string', ':value': values} dia = ParameterDialog(params, store_geometry="open_launch_on_click") dia.setFilterVisible(False) dia.setWindowTitle('Select Parameter') if dia.exec_(): params = dia.getKeywords() search_for = replace_arg(search_for, params) else: # canceled -> cancel interpretation QTextEdit.mouseReleaseEvent(self, event) return # now resolve find-statements rospy.logdebug(" send interpret request to daemon: %s" % search_for) inc_files = nm.nmd().launch.get_interpreted_path(self.filename, text=[search_for]) for path, exists in inc_files: try: rospy.logdebug(" received interpret request from daemon: %s, exists: %d" % (path, exists)) if exists: event.setAccepted(True) self.load_request_signal.emit(path) else: _filename, file_extension = os.path.splitext(path) if file_extension in nm.settings().launch_view_file_ext: # create a new file, if it does not exists result = MessageBox.question(self, "File not exists", '\n\n'.join(["Create a new file?", path]), buttons=MessageBox.Yes | MessageBox.No) if result == MessageBox.Yes: content = '<launch>\n\n</launch>' if path.endswith('.launch') else '' nm.nmd().file.save_file(path, content.encode(), 0) event.setAccepted(True) self.load_request_signal.emit(path) except Exception as e: MessageBox.critical(self, "Error", "File not found %s" % path, detailed_text=utf8(e)) except exceptions.ResourceNotFound as not_found: MessageBox.critical(self, "Error", "Resource not found %s" % search_for, detailed_text=utf8(not_found.error)) except Exception as err: print(traceback.format_exc()) MessageBox.critical(self, "Error", "Error while request included file %s" % self.filename, detailed_text=utf8(err)) QTextEdit.mouseReleaseEvent(self, event)