Files
pyfa/gui/fitCommands/guiChangeProjectedFighterAmount.py
2019-04-13 23:26:53 +03:00

36 lines
1.2 KiB
Python

import wx
import gui.mainFrame
from gui import globalEvents as GE
from .calc.fitChangeProjectedFighterAmount import FitChangeProjectedFighterAmountCommand
from service.fit import Fit
from logbook import Logger
pyfalog = Logger(__name__)
class GuiChangeProjectedFighterAmount(wx.Command):
def __init__(self, fitID, position, amount):
wx.Command.__init__(self, True, "")
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.sFit = Fit.getInstance()
self.fitID = fitID
self.position = position
self.amount = amount
self.internal_history = wx.CommandProcessor()
def Do(self):
cmd = FitChangeProjectedFighterAmountCommand(self.fitID, self.position, self.amount)
if self.internal_history.Submit(cmd):
self.sFit.recalc(self.fitID)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
return True
return False
def Undo(self):
pyfalog.debug("{} Undo()".format(self))
for _ in self.internal_history.Commands:
self.internal_history.Undo()
self.sFit.recalc(self.fitID)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
return True