29 lines
995 B
Python
29 lines
995 B
Python
import wx
|
|
|
|
import gui.mainFrame
|
|
from gui import globalEvents as GE
|
|
from gui.fitCommands.calcCommands.cargo.add import CalcAddCargoCommand
|
|
from gui.fitCommands.helpers import CargoInfo, InternalCommandHistory
|
|
|
|
|
|
class GuiAddCargoCommand(wx.Command):
|
|
|
|
def __init__(self, fitID, itemID, amount):
|
|
wx.Command.__init__(self, True, 'Add Cargo')
|
|
self.internalHistory = InternalCommandHistory()
|
|
self.fitID = fitID
|
|
self.itemID = itemID
|
|
self.amount = amount
|
|
|
|
def Do(self):
|
|
cmd = CalcAddCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=self.amount))
|
|
if self.internalHistory.submit(cmd):
|
|
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
|
return True
|
|
return False
|
|
|
|
def Undo(self):
|
|
success = self.internalHistory.undoAll()
|
|
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
|
return success
|