CMS 3D CMS Logo

UndoEvent.py
Go to the documentation of this file.
1 from __future__ import print_function
2 
4  LABEL = ""
5 
6  def __init__(self):
7  pass
8 
9  def undo(self):
10  """ Undos this event.
11  """
12  raise NotImplementedError
13 
14  def redo(self):
15  """ Repeats this event.
16  """
17  raise NotImplementedError
18 
19  def combine(self, otherUndoEvent):
20  """ Combines this event with another event of the same kind.
21 
22  If the combination was successfull True or otherwise False will be returned.
23  """
24  return False
25 
26  def description(self):
27  """ Returns a string with more detailed explanation of what this event does
28 
29  E.g. what exactly was dragged, moved or which values changed.
30  """
31  return ""
32 
33  def setLastSavedState(self, flag):
34  """ Sets the last saved state flag.
35 
36  If the flag is True, this UndoEvent represents the first action
37  after saving the file for the last time.
38  """
39  self._lastSavedStateFlag = flag
40 
41  def isLastSavedState(self):
42  """ Returns the last saved state flag, see setLastSavedState().
43  """
44  if hasattr(self, "_lastSavedStateFlag"):
45  return self._lastSavedStateFlag
46  return False
47 
48  def dump(self, prefix="undo"):
49  print(prefix, ": ", self.LABEL, self.isLastSavedState())
50 
51 
53  """ This UndoEvent holds a list of UndoEvents whose redo() and undo() are invoked at the same time
54  when the corresponding function of this event is invoked.
55  """
56 
57  LABEL = "Multiple actions"
58 
59  def __init__(self, listOfUndoEvents, label=None):
60  UndoEvent.__init__(self)
61  self._undoEvents = listOfUndoEvents
62  if label:
63  self.LABEL = label
64  if len(self._undoEvents) == 1:
65  self.LABEL = self._undoEvents[0].LABEL
66 
67  labels = []
68  for event in self._undoEvents:
69  if not event.LABEL in labels:
70  labels.append(event.LABEL)
71  if len(labels) > 0:
72  self.LABEL += " (%s)" % ", ".join(labels)
73 
74  def undo(self):
75  for event in self._undoEvents:
76  event.undo()
77 
78  def redo(self):
79  # undo event list comes sorted so that it will work for undo
80  # if events depend on each other its important to reverse order for redo()
81  for event in reversed(self._undoEvents):
82  event.redo()
83 
84  def dump(self, prefix="undo"):
85  UndoEvent.dump(self, prefix)
86  for event in self._undoEvents:
87  event.dump(" " + prefix)
88 
def combine(self, otherUndoEvent)
Definition: UndoEvent.py:19
def setLastSavedState(self, flag)
Definition: UndoEvent.py:33
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def dump(self, prefix="undo")
Definition: UndoEvent.py:48
def __init__(self, listOfUndoEvents, label=None)
Definition: UndoEvent.py:59
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def dump(self, prefix="undo")
Definition: UndoEvent.py:84