1from textual.screen
import Screen
2from textual.widgets
import Footer
3from textual.binding
import Binding
6from daqconf.cider.widgets.custom_rich_log
import RichLogWError
7from daqconf.cider.widgets.config_table
import ConfigTable
8from daqconf.cider.widgets.configuration_controller
import ConfigurationController
9from daqconf.cider.widgets.popups.file_io
import SaveWithMessageScreen, OpenFileScreen
10from daqconf.cider.widgets.popups.dropdown_selector
import SelectSessionScreen
11from daqconf.cider.app_structures.selection_panel
import SelectionPanel
12from daqconf.cider.widgets.popups.quit_screen
import QuitScreen
13from daqconf.cider.widgets.popups.config_object_modifier_screen
import ConfigObjectModifierScreen
14from daqconf.cider.widgets.popups.add_objects
import AddNewObjectScreen
15from daqconf.cider.widgets.popups.delete_object_screen
import DeleteConfigObjectScreen
16from daqconf.cider.widgets.popups.file_io
import RenameConfigObjectScreen
22 """Main screen for navigating python DBE
28 Binding(
"ctrl+s",
"save_configuration_with_message",
"Save Configuration"),
29 Binding(
"o",
"open_configuration",
"Open Configuration"),
30 Binding(
"ctrl+q",
"request_quit",
"Exit Cider"),
31 Binding(
"e",
"modify_relations",
"Modify Relation to Object"),
32 Binding(
"r",
"rename_configuration",
"Rename Conf Object"),
33 Binding(
"d",
"toggle_disable",
"Toggle Disable"),
34 Binding(
"a",
"add_configuration",
"Add Conf Object"),
35 Binding(
"ctrl+d",
"destroy_configuration",
"Delete Conf Object"),
38 _config_controller =
None
42 self.
logger = RichLogWError(id=
"main_log", highlight=
True, markup=
True)
46 self.
logger.write(
"[red]========================================================================")
47 self.
logger.write(
" [bold yellow]Welcome to CIDER![/bold yellow]")
48 self.
logger.write(
" [green]This is a work in progress, please use with[/green] [bold red]caution![/bold red]")
49 self.
logger.write(
"[red]========================================================================\n\n")
52 """Mount widgets with the logger appearing first"""
54 await self.mount(self.
logger)
60 await self.mount(Footer())
70 Update main screen to have a new input file.
76 except Exception
as e:
86 self.mount(SelectionPanel())
87 except Exception
as e:
92 config_table = self.query_one(ConfigTable)
95 config_table = ConfigTable(id=
"main_table")
96 self.mount(config_table)
105 data_base_name = path.basename(current_database_path)
108 self.
logger.write(f
"[bold green]Opened new configuration file: [/bold green][bold red]{data_base_name}[/bold red][bold green].\nConnected databases are:[/bold green]\n" \
109 +
"".join([f
" - [red]{db}[/red] \n" for db
in self.
_config_controller.configuration.get_includes()]))
112 """Updates table based on global state of the configuration controller
114 config_table = self.query_one(ConfigTable)
115 if config_table
is not None:
116 config_table.update_table(event.dal)
119 """Save current configuration
121 config = self.query_one(ConfigurationController)
122 config.commit_configuration(
"Update configuration")
125 """Save current configuration with an update message
127 self.app.push_screen(SaveWithMessageScreen())
130 """Activate open file splash screen
133 await self.app.push_screen(OpenFileScreen())
136 """Toggle disable on the selected configuration object
139 await self.app.push_screen(SelectSessionScreen())
143 self.query_one(RichLogWError).write_error(
"Could not toggle disable configuration object")
147 """Call the quit handler just like action_request_quit."""
148 self.app.push_screen(QuitScreen())
160 self.app.push_screen(ConfigObjectModifierScreen())
164 self.app.push_screen(AddNewObjectScreen())
165 except Exception
as e:
166 self.query_one(RichLogWError).write_error(e)
170 self.app.push_screen(DeleteConfigObjectScreen())
171 except Exception
as e:
172 self.query_one(RichLogWError).write_error(e)
175 self.app.push_screen(RenameConfigObjectScreen())
None action_save_configuration_with_message(self)
on_configuration_controller_changed(self, event)
None action_save_configuration(self)
None action_request_quit(self)
None action_modify_relations(self)
None action_rename_configuration(self)
__make_logger(self, bool splash=False)
None action_destroy_configuration(self)
None action_open_configuration(self)
update_with_new_input(self, str input_file_name)
None action_add_configuration(self)
None action_toggle_disable(self)
handle_sigint(self, signum, frame)
set_initial_input_file(self, str input_file)