Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
content['query'] = self._textareas[name].getText()
else:
content[id]['query'] = self._textareas[name].getText()
SwingUtilities.invokeLater(lambda: self._textareas['raw'].setText(json.dumps(content)))
elif name.startswith('gql_variables#'):
id = int(name.split("#")[1])
content = json.loads(self._textareas['raw'].getText())
if id == 0 and not isinstance(content, list):
content['variables'] = json.loads(self._textareas[name].getText())
else:
content[id]['variables'] = json.loads(self._textareas[name].getText())
SwingUtilities.invokeLater(lambda: self._textareas['raw'].setText(json.dumps(content)))
except ValueError:
pass # Avoid crashing for JSON not valid incompatibilities
_textarea.getDocument().addDocumentListener(_PayloadListener(changed_update=on_change))
return this
def add_listener(self, listener):
"""
add a new listener to the textarea
:param listener: this parameter should be a lambda or a method
:return: None
"""
self._listener = listener
if 'raw' in self._textareas:
self._textareas['raw'].getDocument().addDocumentListener(_PayloadListener(listener))