def menu_will_show(self, item): # item is the parent node which will be None when the # context menu has just being opened. # So when the call is done for a sub-menu, no reset is needed. if item is None: self.menu.remove_all() if item is None: parent_nodes = {} selection = grt.List() pobj = None for node in self.tree.get_selection(): name = node.get_string(self.name_column) obj = grt.classes.db_query_LiveDBObject() obj.name = name obj.schemaName = self.schema obj.type = self.klass if hasattr(self, 'parent_name_column'): if hasattr(self, 'table'): parent_name = self.table else: parent_name = node.get_string( self.parent_name_column) if parent_nodes.has_key(parent_name): obj.owner = parent_nodes[parent_name] else: pobj = grt.classes.db_query_LiveDBObject() obj.owner = pobj pobj.type = 'db.Table' pobj.name = parent_name pobj.schemaName = self.schema parent_nodes[parent_name] = pobj selection.append(obj) if not selection and self.node_name: obj = grt.classes.db_query_LiveDBObject() obj.schemaName = self.schema obj.type = self.node_name selection.append(obj) sobj = grt.classes.db_query_LiveDBObject() sobj.schemaName = self.schema sobj.name = self.schema sobj.type = "db.Schema" obj.owner = sobj separator = mforms.newMenuItem("", mforms.SeparatorMenuItem) separator.set_name("Bottom Plugins Separator") separator.setInternalName("bottom_plugins_separator") self.menu.add_item(separator) self.menu.add_item_with_title("Refresh", self.refresh, "Refresh", "refresh") args = grt.Dict() args["selection"] = selection args["menu"] = mforms.togrt(self.menu, "ContextMenu") args['schema_inspector'] = True NotificationCenter().send("GRNLiveDBObjectMenuWillShow", self.editor, args)
def __init__(self, main): SourceWizardPage.__init__(self, main, "Source Selection") self.supported_sources_instances = grt.List(grt.OBJECT, grt.classes.db_mgmt_Rdbms.__grtclassname__) for rdbms in migration.MigrationPlan.supportedSources(): self.supported_sources_instances.append(rdbms) self.main.add_wizard_page(self, "SourceTarget", "Source Selection")
def generateManifest(moduleName, outpath): module = getattr(grt.modules, moduleName, None) if not module: raise ValueError("Invalid module name") dict = grt.Dict() dict["name"] = module.__name__ dict["iconFile"] = os.path.basename(module.__iconpath__) pluginList = grt.List() dict["plugins"] = pluginList dict["author"] = module.__author__ dict["description"] = module.__description__ dict["version"] = module.__version__ if not hasattr(module, "getPluginInfo"): raise ValueError("Module '%s' is not a plugin module" % moduleName) plugins = module.getPluginInfo() for plugin in plugins: entry = grt.Dict() entry["name"] = plugin.name entry["caption"] = plugin.caption entry["description"] = plugin.description pluginList.append(entry) grt.serialize(dict, outpath) return 0
def getDataSourceNames(cls): result = grt.List(grt.STRING) import pyodbc sources = pyodbc.dataSources() for key, value in list(sources.items()): result.append("%s|%s (%s)" % (key, key, value)) return result
def getMigrationOptions(state): list = grt.List(grt.OBJECT, grt.classes.db_migration_MigrationParameter.__grtclassname__) #param = grt.classes.db_migration_MigrationParameter() #param.name = "generic:mergeSchemaNameToTableName" #param.caption = "Treat source catalogs as schemas in MySQL and merge schema and table names\nex.: MyCatalog.MySchema.MyTable -> MyCatalog.MySchema_MyTable" #list.append(param) return list
def getMigrationOptions(state): list = grt.List(grt.OBJECT, grt.classes.db_migration_MigrationParameter.__grtclassname__) param = grt.classes.db_migration_MigrationParameter() param.name = "postgresql:migrateTimestampAsDatetime" param.caption = "Migrate TIMESTAMP values as DATETIME by default. TIMESTAMP values in MySQL have a limited time range." param.paramType = "boolean" list.append(param) return list
def getMigrationOptions(state): list = grt.List( grt.OBJECT, grt.classes.db_migration_MigrationParameter.__grtclassname__) #param = grt.classes.db_migration_MigrationParameter() #param.name = "mssql:mergeSchemaNameToTableName" #param.caption = "Merge source schema and table names into a single target schema\nex.: AdventureWorks.Person.Contact -> AdventureWorks.Person_Contact" #list.append(param) return list
def run(self): if self.run_modal(self.ok, self.cancel): l = grt.List("object", "model.Diagram") for i, d in enumerate(self.model.diagrams): if self.tree.node_at_row(i).get_bool(0): l.append(d) if not l: mforms.App.get().set_status_text( "No diagrams selected to print") return file = self.file.get_string_value() format = [".pdf", ".ps"][self.format.get_selected_index()] header = self.header.get_string_value() footer = self.footer.get_string_value() self.model.options["wb.PrintModel:Path"] = file self.model.options["wb.PrintModel:HeaderText"] = header self.model.options["wb.PrintModel:FooterText"] = footer if not file: mforms.App.get().set_status_text("Invalid path") if not file.endswith(format): file = file + format mforms.App.get().set_status_text("Exporting diagrams to %s..." % file) def replace_variables(text, model): text = text.replace("$document", model.owner.info.caption) text = text.replace("$doc_version", model.owner.info.version) text = text.replace("$doc_author", model.owner.info.author) text = text.replace("$doc_project", model.owner.info.project) text = text.replace("$doc_date_changed", model.owner.info.dateChanged) text = text.replace("$doc_date_created", model.owner.info.dateCreated) import time text = text.replace("$timestamp", time.ctime()) return text options = { "header_text": replace_variables(header, self.model), "footer_text": replace_variables(footer, self.model), } grt.modules.WbPrinting.printDiagramsToFile(l, file, format[1:], options) mforms.App.get().set_status_text("Exported %i diagrams to %s." % (len(l), file))
def __init__(self, name, implements=None, author="", version= "", description= ""): """Define a GRT module. Must be called before any function declaration as wbmodule = DefineModule('modname') """ self.name= name self.author= author self.version= version self.description= description # List of functions exported by the module (automatically updated by @declare) self.functions= [] # List of interfaces implemented by the module self.implements= implements or [] self._pluginList= grt.List(grt.OBJECT, "app.Plugin")
def run(): import grt import os datadir = mforms.App.get().get_user_data_folder() path = datadir + "/migration_generic_typemap.xml" if grt.root.wb.migration: typemap = grt.root.wb.migration.genericDatatypeMappings else: if os.path.exists(path): typemap = grt.unserialize(path) else: global_path = mforms.App.get().get_resource_path("") global_path += "/modules/data/migration_generic_typemap.xml" if os.path.exists(global_path): typemap = grt.unserialize(global_path) else: typemap = grt.List(grt.OBJECT, "db.migration.DatatypeMapping") form = DatatypeMappingEditor() if form.run(typemap): grt.serialize(typemap, path) return 1 return 0
def getMigrationOptions(state): list = grt.List(grt.OBJECT, grt.classes.db_migration_MigrationParameter.__grtclassname__) return list
def templates(self): tlist = grt.root.wb.options.options.get("TableTemplates", None) if not tlist: tlist = grt.List() grt.root.wb.options.options["TableTemplates"] = tlist return tlist
def getTDSProtocolVersionChoices(): result = grt.List(grt.STRING) result.append("4.1|Sybase Adaptive Server Enterprise 15 (4.1)") return result