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:
|
||||
self.dbstate = dbstate
|
||||
self.uistate = uistate
|
||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
||||
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||
if not self.fail:
|
||||
ToolManagedWindowBase.__init__(self, dbstate, uistate,
|
||||
options_class, name, callback)
|
||||
|
@ -99,25 +99,27 @@ class Tool(object):
|
||||
class BatchTool(Tool):
|
||||
"""
|
||||
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):
|
||||
# TODO: should we replace this with a callback?
|
||||
from QuestionDialog import QuestionDialog2
|
||||
warn_dialog = QuestionDialog2(
|
||||
_('Undo history warning'),
|
||||
_('Proceeding with this tool will erase the undo history '
|
||||
'for this session. In particular, you will not be able '
|
||||
'to revert the changes made by this tool or any changes '
|
||||
'made prior to it.\n\n'
|
||||
'If you think you may want to revert running this tool, '
|
||||
'please stop here and backup your database.'),
|
||||
_('_Proceed with the tool'), _('_Stop'))
|
||||
if not warn_dialog.run():
|
||||
self.fail = True
|
||||
return
|
||||
def __init__(self, dbstate, uistate, options_class, name):
|
||||
if uistate:
|
||||
# TODO: should we replace this with a callback?
|
||||
from QuestionDialog import QuestionDialog2
|
||||
warn_dialog = QuestionDialog2(
|
||||
_('Undo history warning'),
|
||||
_('Proceeding with this tool will erase the undo history '
|
||||
'for this session. In particular, you will not be able '
|
||||
'to revert the changes made by this tool or any changes '
|
||||
'made prior to it.\n\n'
|
||||
'If you think you may want to revert running this tool, '
|
||||
'please stop here and backup your database.'),
|
||||
_('_Proceed with the tool'), _('_Stop'))
|
||||
if not warn_dialog.run():
|
||||
self.fail = True
|
||||
return
|
||||
|
||||
Tool.__init__(self, dbstate, options_class, name)
|
||||
self.fail = False
|
||||
|
@ -78,7 +78,7 @@ class ChangeNames(tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
ManagedWindow.ManagedWindow.__init__(self,uistate,[],self.__class__)
|
||||
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:
|
||||
return
|
||||
|
||||
|
@ -56,7 +56,7 @@ class ChangeTypes(tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
|
||||
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:
|
||||
return
|
||||
|
||||
|
@ -123,7 +123,7 @@ def cross_table_duplicates(db):
|
||||
class Check(tool.BatchTool):
|
||||
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:
|
||||
return
|
||||
|
||||
|
@ -68,7 +68,7 @@ class EventNames(tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
"""
|
||||
|
||||
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:
|
||||
uistate.set_busy_cursor(True)
|
||||
|
@ -417,7 +417,7 @@ class ExtractCity(tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__)
|
||||
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:
|
||||
uistate.set_busy_cursor(True)
|
||||
|
@ -94,7 +94,7 @@ class MergeCitations(tool.BatchTool,ManagedWindow.ManagedWindow):
|
||||
self.dbstate = dbstate
|
||||
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:
|
||||
uistate.set_busy_cursor(True)
|
||||
|
@ -107,7 +107,7 @@ class PatchNames(tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__)
|
||||
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:
|
||||
return
|
||||
|
||||
|
@ -57,7 +57,7 @@ _parseformat = re.compile('.*%(\d+)[^\d]+')
|
||||
#-------------------------------------------------------------------------
|
||||
class ReorderIds(tool.BatchTool):
|
||||
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:
|
||||
return
|
||||
|
||||
|
@ -110,7 +110,7 @@ class TestcaseGenerator(tool.BatchTool):
|
||||
if dbstate.db.readonly:
|
||||
return
|
||||
|
||||
tool.BatchTool.__init__(self, dbstate, options_class, name)
|
||||
tool.BatchTool.__init__(self, dbstate, uistate, options_class, name)
|
||||
|
||||
if self.fail:
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user