Beispiel #1
0
def build_sql_tab(parent):
    '''
    Builds "SQL" tab subtree of widgets

    Parameters:
        parent (Widget): Parent widget of tab subtree

    Returns:
        Widget: Subtree of widgets
    '''
    sql = Tab('SQL', parent, ord('q'))
    sql.resize(height = 22)

    input_group = sql.content_region
    input_group.scale(width = -38)

    translator = DatasigTranslator(input_group)
    translator.map_output('DB_RAW_QUERY', text = 'raw')

    form = Form(translator, text = '')

    text_in = TextBox('Input', form, ord('i'))
    text_in.scale(height = -2)
    text_in.linked_label.embellish(' ', ' ').offset(x = 2)

    translator = DatasigTranslator(form)
    translator.map_output('UI_SUBMIT')

    submit = Button('Submit', translator, ord('s'))
    submit.move(y = 16)

    translator = DatasigTranslator(form)
    translator.map_output('UI_CLEAR_FORM')

    reset = Button('Reset', translator, ord('r'))
    reset.move(x = 12, y = 16)

    output_group = sql.content_region
    output_group.scale(width = -38).offset(x = 38)

    form = Form(output_group)

    translator = DatasigTranslator(form)
    translator.map_input('UI_RAW_QUERY', result = 'text')
    translator.map_focus('UI_RAW_QUERY')

    text_out = TextBox('Output', translator, ord('o'))
    text_out.read_only()
    text_out.scale(height = -2)
    text_out.linked_label.embellish(' ', ' ').offset(x = 2)

    translator = DatasigTranslator(form)
    translator.map_output('UI_CLEAR_FORM')

    clear = Button('Clear', translator, ord('c'))
    clear.move(y = 16)

    return sql
Beispiel #2
0
def build_table_tab(parent):
    '''
    Builds "Table" tab subtree of widgets

    Parameters:
        parent (Widget): Parent widget of tab subtree

    Returns:
        Widget: Subtree of widgets
    '''
    table = Tab('Table', parent, ord('t'))
    table.resize(height = 22)
    table_group = table.content_region

    translator = DatasigTranslator(table_group)
    translator.map_input('UI_TABLE_LIST', tables = 'options')
    translator.map_output('DB_SET_TABLE', option = 'table')
    translator.map_request('DB_LIST_TABLES')

    table_list = SelectField('Table List', translator, ord('t'))
    table_list.auto_expand()
    table_list.limit_options(5)
    table_list.resize(width = 30)
    table_list.align('CENTER')
    table_list.linked_label.embellish(suffix = ': ').to_center(cross = True).shift(-1)

    tab_group = table.content_region.scale(height = -3).offset(y = 3)

    content_tab = VertTab('Content', tab_group, ord('c'))
    structure_tab = VertTab('Structure', tab_group, ord('s'))

    content_tab_group = content_tab.content_region
    content_tab_group.outset(1).scale(width = -2).offset(x = 2)

    structure_tab_group = structure_tab.content_region
    structure_tab_group.outset(1).scale(width = -2).offset(x = 2)

    translator = DatasigTranslator(content_tab_group)
    translator.map_input('UI_TABLE_CONTENT', table_content = 'table')
    translator.map_request('DB_TABLE_CONTENT')

    table_content = Table('Inspect Table', translator, ord('i'))
    table_content.linked_label.hide()
    table_content.add_signal_handler('UI_SET_TABLE', table_content.request)

    translator = DatasigTranslator(structure_tab_group)
    translator.map_input('UI_TABLE_STRUCTURE', table_structure = 'table')
    translator.map_request('DB_TABLE_STRUCTURE')

    table_structure = Table('Inspect Table', translator, ord('i'))
    table_structure.linked_label.hide()
    table_structure.add_signal_handler('UI_SET_TABLE', table_structure.request)

    return table
Beispiel #3
0
def build_database_tab(parent):
    '''
    Builds "Database" tab subtree of widgets

    Parameters:
        parent (Widget): Parent widget of tab subtree

    Returns:
        Widget: Subtree of widgets
    '''
    database = Tab('Database', parent, ord('d'))
    database.resize(height = 22)
    database_group = database.content_region

    translator = DatasigTranslator(database_group)
    translator.map_input('UI_DATABASE_LIST', databases = 'options')
    translator.map_output('DB_SET_DATABASE', option = 'database')
    translator.map_request('DB_LIST_DATABASES')

    database_list = SelectField('Database List', translator, ord('d'))
    database_list.auto_expand()
    database_list.resize(width = 30)
    database_list.align('CENTER')
    database_list.linked_label.embellish(suffix = ': ').to_center(cross = True).shift(-1)

    tab_group = database.content_region.scale(height = -3).offset(y = 3)

    import_tab = VertTab('Import', tab_group, ord('i'))
    export_tab = VertTab('Export', tab_group, ord('e'))

    import_tab_group = import_tab.content_region
    export_tab_group = export_tab.content_region

    translator = DatasigTranslator(import_tab_group)
    translator.map_output('DB_IMPORT_DATABASE')

    form = Form(
        translator,
        pathname = '', filename = '', clean = False
    )

    translator = DatasigTranslator(form)
    translator.map_output('DATASIG_OUT', text = 'pathname')

    import_path = TextField('Path', translator, ord('p'))
    import_path.scale(width = -12).offset(x = 12)
    import_path.linked_label.embellish(suffix = ': ').to_center(cross = True).shift(-1)

    translator = DatasigTranslator(form)
    translator.map_output('DATASIG_OUT', text = 'filename')

    import_file = TextField('Filename', translator, ord('f'))
    import_file.scale(width = -12).offset(12, 3)
    import_file.linked_label.embellish(suffix = ': ').to_center(cross = True).shift(-1)

    translator = DatasigTranslator(form)
    translator.map_output('DATASIG_OUT', enabled = 'clean')

    overwrite = FlipSwitch('Overwrite Existing', translator, ord('o'))
    overwrite.offset(32, 6)
    overwrite.linked_label.embellish(suffix = ': ').to_center(cross = True).shift(-1)

    translator = DatasigTranslator(form)
    translator.map_output('UI_SUBMIT')

    import_button = Button('Import', translator, ord('i'))
    import_button.offset(12, 10)

    translator = DatasigTranslator(export_tab_group)
    translator.map_output('DB_EXPORT_DATABASE')

    form = Form(
        translator,
        pathname = '', filename = '', plain = False, schema = False
    )

    translator = DatasigTranslator(form)
    translator.map_output('DATASIG_OUT', text = 'pathname')

    export_path = TextField('Path', translator, ord('p'))
    export_path.scale(width = -12).offset(x = 12)
    export_path.linked_label.embellish(suffix = ': ').to_center(cross = True).shift(-1)

    translator = DatasigTranslator(form)
    translator.map_output('DATASIG_OUT', text = 'filename')

    export_file = TextField('Filename', translator, ord('f'))
    export_file.scale(width = -12).offset(12, 3)
    export_file.linked_label.embellish(suffix = ': ').to_center(cross = True).shift(-1)

    translator = DatasigTranslator(form)
    translator.map_output('DATASIG_OUT', enabled = 'plain')

    plaintext = FlipSwitch('Plain Text', translator, ord('t'))
    plaintext.offset(24, 6)
    plaintext.linked_label.embellish(suffix = ': ').to_center(cross = True).shift(-1)

    translator = DatasigTranslator(form)
    translator.map_output('DATASIG_OUT', enabled = 'schema')

    schema_only = FlipSwitch('Schema Only', translator, ord('s'))
    schema_only.offset(50, 6)
    schema_only.linked_label.embellish(suffix = ': ').to_center(cross = True).shift(-1)

    translator = DatasigTranslator(form)
    translator.map_output('UI_SUBMIT')

    export_button = Button('Export', translator, ord('e'))
    export_button.offset(12, 10)

    return database