Beispiel #1
0
def review_sql_code(code):
    form = mforms.Form(mforms.Form.main_form(), mforms.FormNormal)
    form.set_title("Review SQL Code to Execute")
    box = mforms.newBox(False)
    box.set_padding(12)
    form.set_content(box)

    box.set_spacing(8)
    box.add(mforms.newLabel("Review the SQL code to be executed."), False,
            True)

    editor = mforms.CodeEditor()
    box.add(editor, True, True)
    editor.set_language(mforms.LanguageMySQL)
    editor.set_text(code)
    editor.set_features(mforms.FeatureReadOnly, True)

    ok = mforms.newButton()
    ok.set_text("Execute")
    cancel = mforms.newButton()
    cancel.set_text("Cancel")

    bbox = mforms.newBox(True)
    bbox.set_spacing(8)
    bbox.add_end(ok, False, True)
    bbox.add_end(cancel, False, True)
    box.add_end(bbox, False, True)

    form.set_size(500, 360)
    return form.run_modal(ok, cancel)
Beispiel #2
0
def selectServer(title):
    # No need to select an instance if there's only one:
    if len(grt.root.wb.rdbmsMgmt.storedInstances) == 1:
        return grt.root.wb.rdbmsMgmt.storedInstances[0]

    window = mforms.Form(None)
    window.set_title(title)
    box = mforms.newBox(False)
    window.set_content(box)

    box.set_padding(12)
    box.set_spacing(12)

    label = mforms.newLabel()
    label.set_text("Select Server to Connect to:")
    box.add(label, False, True)

    listbox = mforms.newListBox(False)
    box.add(listbox, True, True)
    listbox.show()

    for inst in grt.root.wb.rdbmsMgmt.storedInstances:
        listbox.add_item(inst.name)

    if len(grt.root.wb.rdbmsMgmt.storedInstances) > 0:
        listbox.set_selected(0)
    else:
        Utilities.show_warning(
            "No Database Server Instances",
            '''You have not defined a database server instance. At least one
    server instance is needed. Please define one by clicking in 
    "New Server Instance" and retry.''', "OK", "", "")
        return None

    bbox = mforms.newBox(True)
    box.add(bbox, False, True)

    bbox.set_spacing(8)

    ok = mforms.newButton()
    ok.set_text("OK")
    bbox.add_end(ok, False, True)

    cancel = mforms.newButton()
    cancel.set_text("Cancel")
    bbox.add_end(cancel, False, True)

    window.set_size(400, 300)
    window.center()

    if window.run_modal(ok, cancel):
        i = listbox.get_selected_index()
        if i >= 0:
            return grt.root.wb.rdbmsMgmt.storedInstances[i]
    return None
Beispiel #3
0
def quickTablesInCatalog(catalog):

    form = mforms.Form(None, mforms.FormDialogFrame)
    label = mforms.newLabel(
        """You can create multiple tables by giving their outline in the following format:
    table1 *column1 int,column2 varchar(32),column3
    table2 column1,column2
    table3
    ... 

* denotes a primary key column. Column type is optional.""")

    box = mforms.newBox(False)
    box.set_spacing(12)
    box.set_padding(12)
    box.add(label, False, False)
    text = mforms.newTextBox(mforms.VerticalScrollBar)
    box.add(text, True, True)

    form.set_content(box)
    form.set_title("Create Multiple Tables")

    ok = mforms.newButton()
    ok.set_text("OK")
    cancel = mforms.newButton()
    cancel.set_text("Cancel")

    bbox = mforms.newBox(True)
    mforms.Utilities.add_end_ok_cancel_buttons(bbox, ok, cancel)
    bbox.set_spacing(8)
    box.add_end(bbox, False, True)

    form.set_size(600, 350)
    form.center()

    schema = catalog.schemata[0]
    ok.add_clicked_callback(lambda: form.end_modal(True))
    if form.run_modal(None, cancel):
        tabledefs = _parse_table_definitions(text.get_string_value())
        for name, columns in tabledefs:
            if name:
                _create_table(catalog, schema, name, columns)
        return 1
    return 0
Beispiel #4
0
def selectServer(title):
    window = mforms.Form(None)
    window.set_title(title)
    box = mforms.newBox(False)
    window.set_content(box)

    box.set_padding(12)
    box.set_spacing(12)

    label = mforms.newLabel()
    label.set_text("Select Server to Connect to:")
    box.add(label, False, True)

    listbox = mforms.newListBox(False)
    box.add(listbox, True, True)
    listbox.show()

    for inst in grt.root.wb.rdbmsMgmt.storedInstances:
        listbox.add_item(inst.name)

    bbox = mforms.newBox(True)
    box.add(bbox, False, True)

    bbox.set_spacing(8)

    ok = mforms.newButton()
    ok.set_text("OK")
    bbox.add_end(ok, False, True)

    cancel = mforms.newButton()
    cancel.set_text("Cancel")
    bbox.add_end(cancel, False, True)

    window.set_size(400, 300)
    window.center()

    if window.run_modal(ok, cancel):
        i = listbox.get_selected_index()
        if i >= 0:
            return grt.root.wb.rdbmsMgmt.storedInstances[i]
    return None
class NameSource(object):
    def get_typed_value(self, name):
        return (name, mforms.CellText, False)


class ValueSource(object):
    def get_typed_value(self, name):
        if name[1] in ['a', 'b', 'c', 'd']:
            lst = ["1", "2", "3", "4", "5", "6"]
            return (lst[random.randint(0, len(lst) - 1)], mforms.CellEnum, lst)
        else:
            return (name, mforms.CellText, True)


frm = mforms.Form(None, mforms.FormResizable)

grid = mforms.newSimpleGrid()

layout = wba_config_file_be.WBAOptionsLayout(grid, options_layout.layout,
                                             ["Option name", "Option value"])

layout.add_source(NameSource(), "Option name")
layout.add_source(ValueSource(), "Option value")

layout.rebuild_ui(options_layout.layout)
layout.update_ui()

frm.set_content(grid)
frm.set_size(700, 600)
frm.show()
Beispiel #6
0
        for x in range(self.values_tree.count()):
            node = self.values_tree.node_at_row(x)
            l.append((node.get_string(0).encode("utf-8"),
                      self.split_groups(node.get_string(1))))

        import pprint
        f = open(self.output_path, "w+")
        f.write("variable_groups = ")
        pp = pprint.PrettyPrinter(indent=2, stream=f)
        pp.pprint(l)
        f.close()


script_dir = os.getcwd()

form = mforms.Form(None, 0)
form.set_size(800, 600)

file_chooser = mforms.newFileChooser(form, mforms.OpenDirectory)

file_chooser.set_title('Choose the base directory')
file_chooser.set_path(script_dir)
file_chooser_result = file_chooser.run_modal()
print "File chooser result: %s" % file_chooser_result
if not file_chooser_result:
    sys.exit()

temp_path = file_chooser.get_path()
sys.path.append(temp_path)

import variable_groups