Created
September 29, 2015 10:43
-
-
Save sqlstunts/2c8050efd7fdb371f133 to your computer and use it in GitHub Desktop.
Refactor plugin for MySQL Workbench.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import the wb module | |
from wb import * | |
# import the grt module | |
import grt | |
# import the mforms module for GUI stuff | |
import mforms | |
# define this Python module as a GRT module | |
ModuleInfo = DefineModule(name="Refactor", author="mjlmo", version="0.1") | |
@ModuleInfo.plugin("wb.text.refactor", caption = "Refactor Selection", input=[wbinputs.currentQueryBuffer()], pluginMenu= "SQL/Utilities") | |
@ModuleInfo.export(grt.INT, grt.classes.db_query_QueryBuffer) | |
def refactorText(editor): | |
fulltext=editor.script | |
text = editor.selectedText | |
if not text: | |
mforms.Utilities.show_warning("No selection","No text selected for refactoring.","OK","","") | |
else: | |
ret, new_text=mforms.Utilities.request_input("New Text","Enter the text to replace with","") | |
editor.replaceContents(fulltext.replace(text,new_text)) | |
return 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment