Files
pyfa/gui/fitCommands/gui/shipModeChange.py
2019-04-15 18:05:18 +03:00

30 lines
1.0 KiB
Python

import wx
from service.fit import Fit
import gui.mainFrame
from gui import globalEvents as GE
from gui.fitCommands.helpers import InternalCommandHistory
from gui.fitCommands.calc.shipModeChange import CalcChangeShipModeCommand
class GuiChangeShipModeCommand(wx.Command):
def __init__(self, fitID, itemID):
wx.Command.__init__(self, True, 'Change Ship Mode')
self.internalHistory = InternalCommandHistory()
self.fitID = fitID
self.itemID = itemID
def Do(self):
cmd = CalcChangeShipModeCommand(fitID=self.fitID, itemID=self.itemID)
success = self.internalHistory.submit(cmd)
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return success
def Undo(self):
success = self.internalHistory.undoAll()
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return success