Handle accept button by creating command and pushing to history.
(self)
| 87 | return {"code": self.code_editor.toPlainText(), "gui_code": self.gui_editor.toPlainText(), "gui_logic_code": self.gui_logic_editor.toPlainText()} |
| 88 | |
| 89 | def _handle_accept(self): |
| 90 | """Handle accept button by creating command and pushing to history.""" |
| 91 | try: |
| 92 | # Get current editor content |
| 93 | new_code = self.code_editor.toPlainText() |
| 94 | new_gui_code = self.gui_editor.toPlainText() |
| 95 | new_gui_logic_code = self.gui_logic_editor.toPlainText() |
| 96 | |
| 97 | # Create command for execution code changes |
| 98 | if new_code != self.original_code: |
| 99 | from commands.node_commands import CodeChangeCommand |
| 100 | code_command = CodeChangeCommand( |
| 101 | self.node_graph, self.node, self.original_code, new_code |
| 102 | ) |
| 103 | # Push command to graph's history if it exists |
| 104 | if hasattr(self.node_graph, 'command_history'): |
| 105 | self.node_graph.command_history.execute_command(code_command) |
| 106 | else: |
| 107 | # Fallback: execute directly |
| 108 | code_command.execute() |
| 109 | |
| 110 | # Handle GUI code changes with direct method calls (not part of story scope) |
| 111 | if new_gui_code != self.original_gui_code: |
| 112 | self.node.set_gui_code(new_gui_code) |
| 113 | |
| 114 | if new_gui_logic_code != self.original_gui_logic_code: |
| 115 | self.node.set_gui_get_values_code(new_gui_logic_code) |
| 116 | |
| 117 | # Accept the dialog |
| 118 | self.accept() |
| 119 | |
| 120 | except Exception as e: |
| 121 | print(f"Error handling code editor accept: {e}") |
| 122 | # Still accept the dialog to avoid blocking user |
| 123 | self.accept() |
nothing calls this directly
no test coverage detected