6953: remove "undo history warning" under CLI
To remove the meaningless "undo history warning" when a BatchTool is run from cli (e.g., "check"), we add to BatchTool constructor an extra argument to get the uistate, and only produce the GUI warning if there is GUI. svn: r22894
This commit is contained in:
parent
192e32cdf4
commit
baae86787c
@ -1029,7 +1029,7 @@ class ToolManagedWindowBatch(tool.BatchTool, ToolManagedWindowBase):
|
|||||||
# This constructor will ask a question, set self.fail:
|
# This constructor will ask a question, set self.fail:
|
||||||
self.dbstate = dbstate
|
self.dbstate = dbstate
|
||||||
self.uistate = uistate
|
self.uistate = uistate
|
||||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||||
if not self.fail:
|
if not self.fail:
|
||||||
ToolManagedWindowBase.__init__(self, dbstate, uistate,
|
ToolManagedWindowBase.__init__(self, dbstate, uistate,
|
||||||
options_class, name, callback)
|
options_class, name, callback)
|
||||||
|
@ -99,25 +99,27 @@ class Tool(object):
|
|||||||
class BatchTool(Tool):
|
class BatchTool(Tool):
|
||||||
"""
|
"""
|
||||||
Same as Tool, except the warning is displayed about the potential
|
Same as Tool, except the warning is displayed about the potential
|
||||||
loss of undo history. Should be used for tools using batch transactions.
|
loss of undo history when GUI is available.
|
||||||
|
Should be used for tools using batch transactions.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, dbstate, options_class, name):
|
def __init__(self, dbstate, uistate, options_class, name):
|
||||||
# TODO: should we replace this with a callback?
|
if uistate:
|
||||||
from QuestionDialog import QuestionDialog2
|
# TODO: should we replace this with a callback?
|
||||||
warn_dialog = QuestionDialog2(
|
from QuestionDialog import QuestionDialog2
|
||||||
_('Undo history warning'),
|
warn_dialog = QuestionDialog2(
|
||||||
_('Proceeding with this tool will erase the undo history '
|
_('Undo history warning'),
|
||||||
'for this session. In particular, you will not be able '
|
_('Proceeding with this tool will erase the undo history '
|
||||||
'to revert the changes made by this tool or any changes '
|
'for this session. In particular, you will not be able '
|
||||||
'made prior to it.\n\n'
|
'to revert the changes made by this tool or any changes '
|
||||||
'If you think you may want to revert running this tool, '
|
'made prior to it.\n\n'
|
||||||
'please stop here and backup your database.'),
|
'If you think you may want to revert running this tool, '
|
||||||
_('_Proceed with the tool'), _('_Stop'))
|
'please stop here and backup your database.'),
|
||||||
if not warn_dialog.run():
|
_('_Proceed with the tool'), _('_Stop'))
|
||||||
self.fail = True
|
if not warn_dialog.run():
|
||||||
return
|
self.fail = True
|
||||||
|
return
|
||||||
|
|
||||||
Tool.__init__(self, dbstate, options_class, name)
|
Tool.__init__(self, dbstate, options_class, name)
|
||||||
self.fail = False
|
self.fail = False
|
||||||
|
@ -78,7 +78,7 @@ class ChangeNames(tool.BatchTool, ManagedWindow.ManagedWindow):
|
|||||||
ManagedWindow.ManagedWindow.__init__(self,uistate,[],self.__class__)
|
ManagedWindow.ManagedWindow.__init__(self,uistate,[],self.__class__)
|
||||||
self.set_window(gtk.Window(),gtk.Label(),'')
|
self.set_window(gtk.Window(),gtk.Label(),'')
|
||||||
|
|
||||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||||
if self.fail:
|
if self.fail:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ class ChangeTypes(tool.BatchTool, ManagedWindow.ManagedWindow):
|
|||||||
|
|
||||||
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
||||||
|
|
||||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||||
if self.fail:
|
if self.fail:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ def cross_table_duplicates(db):
|
|||||||
class Check(tool.BatchTool):
|
class Check(tool.BatchTool):
|
||||||
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
||||||
|
|
||||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||||
if self.fail:
|
if self.fail:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class EventNames(tool.BatchTool, ManagedWindow.ManagedWindow):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
||||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||||
|
|
||||||
if not self.fail:
|
if not self.fail:
|
||||||
uistate.set_busy_cursor(True)
|
uistate.set_busy_cursor(True)
|
||||||
|
@ -417,7 +417,7 @@ class ExtractCity(tool.BatchTool, ManagedWindow.ManagedWindow):
|
|||||||
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__)
|
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__)
|
||||||
self.set_window(gtk.Window(), gtk.Label(), '')
|
self.set_window(gtk.Window(), gtk.Label(), '')
|
||||||
|
|
||||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||||
|
|
||||||
if not self.fail:
|
if not self.fail:
|
||||||
uistate.set_busy_cursor(True)
|
uistate.set_busy_cursor(True)
|
||||||
|
@ -94,7 +94,7 @@ class MergeCitations(tool.BatchTool,ManagedWindow.ManagedWindow):
|
|||||||
self.dbstate = dbstate
|
self.dbstate = dbstate
|
||||||
self.set_window(gtk.Window(), gtk.Label(), '')
|
self.set_window(gtk.Window(), gtk.Label(), '')
|
||||||
|
|
||||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||||
|
|
||||||
if not self.fail:
|
if not self.fail:
|
||||||
uistate.set_busy_cursor(True)
|
uistate.set_busy_cursor(True)
|
||||||
|
@ -107,7 +107,7 @@ class PatchNames(tool.BatchTool, ManagedWindow.ManagedWindow):
|
|||||||
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__)
|
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__)
|
||||||
self.set_window(gtk.Window(), gtk.Label(), '')
|
self.set_window(gtk.Window(), gtk.Label(), '')
|
||||||
|
|
||||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||||
if self.fail:
|
if self.fail:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ _parseformat = re.compile('.*%(\d+)[^\d]+')
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class ReorderIds(tool.BatchTool):
|
class ReorderIds(tool.BatchTool):
|
||||||
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
||||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||||
if self.fail:
|
if self.fail:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
if dbstate.db.readonly:
|
if dbstate.db.readonly:
|
||||||
return
|
return
|
||||||
|
|
||||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||||
|
|
||||||
if self.fail:
|
if self.fail:
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user