|
59 | 59 | # worth it for a while. |
60 | 60 |
|
61 | 61 | import math |
| 62 | +from pathlib import Path |
62 | 63 |
|
63 | 64 | import numpy as np |
64 | 65 |
|
@@ -1152,34 +1153,40 @@ def activate_cell(self, index: QModelIndex): |
1152 | 1153 | global_h_pos = model.h_offset + index.column() |
1153 | 1154 | new_data = model.adapter.cell_activated(global_v_pos, global_h_pos) |
1154 | 1155 | if new_data is not None: |
| 1156 | + # the adapter wants us to open a sub-element |
1155 | 1157 | editor_widget = self.parent().parent() |
1156 | 1158 | assert isinstance(editor_widget, ArrayEditorWidget) |
1157 | 1159 | adapter_creator = get_adapter_creator(new_data) |
1158 | | - if adapter_creator is not None: |
1159 | | - if adapter_creator is get_path_suffix_adapter: |
1160 | | - adapter = get_path_suffix_adapter(new_data, {}) |
1161 | | - if adapter is None: |
1162 | | - logger.info("File type not handled") |
1163 | | - return |
1164 | | - from larray_editor.editor import AbstractEditorWindow, MappingEditorWindow |
1165 | | - widget = self |
1166 | | - while (widget is not None and |
1167 | | - not isinstance(widget, AbstractEditorWindow) and |
1168 | | - callable(widget.parent)): |
1169 | | - widget = widget.parent() |
1170 | | - if isinstance(widget, MappingEditorWindow): |
1171 | | - kernel = widget.kernel |
1172 | | - if kernel is not None: |
1173 | | - # make the current object available in the console |
1174 | | - kernel.shell.push({ |
1175 | | - '__current__': new_data |
1176 | | - }) |
1177 | | - # TODO: we should add an operand on the future quickbar instead |
1178 | | - editor_widget.back_button_bar.add_back(editor_widget.data, |
1179 | | - editor_widget.data_adapter) |
1180 | | - # TODO: we should open a new window instead (see above) |
1181 | | - editor_widget.set_data(new_data) |
| 1160 | + if adapter_creator is None: |
| 1161 | + if isinstance(new_data, Path): |
| 1162 | + title = "File type not supported" |
| 1163 | + msg = f"Cannot display {new_data.suffix} files" |
| 1164 | + else: |
| 1165 | + obj_type = type(new_data) |
| 1166 | + title = "Object type not supported" |
| 1167 | + msg = f"Cannot display objects of type {obj_type.__name__}" |
| 1168 | + QMessageBox.information(self, title, msg) |
1182 | 1169 | return True |
| 1170 | + |
| 1171 | + from larray_editor.editor import AbstractEditorWindow, MappingEditorWindow |
| 1172 | + widget = self |
| 1173 | + while (widget is not None and |
| 1174 | + not isinstance(widget, AbstractEditorWindow) and |
| 1175 | + callable(widget.parent)): |
| 1176 | + widget = widget.parent() |
| 1177 | + if isinstance(widget, MappingEditorWindow): |
| 1178 | + kernel = widget.kernel |
| 1179 | + if kernel is not None: |
| 1180 | + # make the current object available in the console |
| 1181 | + kernel.shell.push({ |
| 1182 | + '__current__': new_data |
| 1183 | + }) |
| 1184 | + # TODO: we should add an operand on the future quickbar instead |
| 1185 | + editor_widget.back_button_bar.add_back(editor_widget.data, |
| 1186 | + editor_widget.data_adapter) |
| 1187 | + # TODO: we should open a new window instead (see above) |
| 1188 | + editor_widget.set_data(new_data) |
| 1189 | + return True |
1183 | 1190 | return False |
1184 | 1191 |
|
1185 | 1192 | class ScrollBar(QScrollBar): |
|
0 commit comments