Example #1
0
 def Undo(self):
     pyfalog.debug('Undoing removal of local modules {} on fit {}'.format(self.savedModInfos, self.fitID))
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     results = []
     from .localReplace import CalcReplaceLocalModuleCommand
     # Restore subsystems 1st
     if len(self.savedSubInfos) > 0:
         for position, modInfo in self.savedSubInfos.items():
             cmd = CalcReplaceLocalModuleCommand(
                 fitID=self.fitID,
                 position=position,
                 newModInfo=modInfo,
                 ignoreRestrictions=True)
             results.append(cmd.Do())
         sFit.recalc(fit)
     for position, modInfo in self.savedModInfos.items():
         cmd = CalcReplaceLocalModuleCommand(
             fitID=self.fitID,
             position=position,
             newModInfo=modInfo,
             ignoreRestrictions=True)
         results.append(cmd.Do())
     if not any(results):
         return False
     restoreCheckedStates(fit, self.savedStateCheckChanges)
     return True
Example #2
0
 def Undo(self):
     pyfalog.debug('Undoing addition of projected fit {} for fit {}'.format(
         self.projectedFitID, self.fitID))
     if self.changeAmountCommand is not None:
         if not self.changeAmountCommand.Undo():
             return False
         restoreCheckedStates(Fit.getInstance().getFit(self.fitID),
                              self.savedStateCheckChanges)
         if self.commit:
             eos.db.commit()
         return True
     # Can't find the projected fit, it must have been deleted. Just skip, as deleted fit
     # means that someone else just did exactly what we wanted to do
     projectedFit = Fit.getInstance().getFit(self.projectedFitID,
                                             projected=True)
     if projectedFit is not None:
         from .remove import CalcRemoveProjectedFitCommand
         cmd = CalcRemoveProjectedFitCommand(
             fitID=self.fitID,
             projectedFitID=self.projectedFitID,
             amount=self.amount,
             commit=False)
         if not cmd.Do():
             return False
     restoreCheckedStates(Fit.getInstance().getFit(self.fitID),
                          self.savedStateCheckChanges)
     if self.commit:
         eos.db.commit()
     return True
Example #3
0
 def Undo(self):
     pyfalog.debug(
         'Undoing addition of projected module {} onto: {}'.format(
             self.newModInfo, self.fitID))
     if self.oldPosition is not None and self.oldModInfo is not None:
         cmd = CalcAddProjectedModuleCommand(fitID=self.fitID,
                                             modInfo=self.oldModInfo,
                                             position=self.oldPosition,
                                             ignoreRestrictions=True,
                                             commit=False)
         if not cmd.Do():
             return False
         restoreCheckedStates(Fit.getInstance().getFit(self.fitID),
                              self.savedStateCheckChanges)
         if self.commit:
             eos.db.commit()
         return True
     from .projectedRemove import CalcRemoveProjectedModuleCommand
     cmd = CalcRemoveProjectedModuleCommand(fitID=self.fitID,
                                            position=self.newPosition,
                                            commit=False)
     if not cmd.Do():
         return False
     restoreCheckedStates(Fit.getInstance().getFit(self.fitID),
                          self.savedStateCheckChanges)
     if self.commit:
         eos.db.commit()
     return True
Example #4
0
 def Undo(self):
     pyfalog.debug('Undoing removal of local modules {} on fit {}'.format(
         self.savedModInfos, self.fitID))
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     results = []
     from .localReplace import CalcReplaceLocalModuleCommand
     # Restore subsystems 1st
     if len(self.savedSubInfos) > 0:
         for position, modInfo in self.savedSubInfos.items():
             cmd = CalcReplaceLocalModuleCommand(fitID=self.fitID,
                                                 position=position,
                                                 newModInfo=modInfo,
                                                 ignoreRestrictions=True)
             results.append(cmd.Do())
         sFit.recalc(fit)
     for position, modInfo in self.savedModInfos.items():
         cmd = CalcReplaceLocalModuleCommand(fitID=self.fitID,
                                             position=position,
                                             newModInfo=modInfo,
                                             ignoreRestrictions=True)
         results.append(cmd.Do())
     if not any(results):
         return False
     restoreCheckedStates(fit, self.savedStateCheckChanges)
     return True
Example #5
0
 def Undo(self):
     pyfalog.debug(
         'Undoing replacement of local module at position {} to {} on fit {}'
         .format(self.position, self.newModInfo, self.fitID))
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     # Remove if there was no module
     if self.oldModInfo is None:
         from .localRemove import CalcRemoveLocalModulesCommand
         cmd = CalcRemoveLocalModulesCommand(fitID=self.fitID,
                                             positions=[self.position],
                                             recalc=False)
         if not cmd.Do():
             return False
         restoreCheckedStates(fit, self.savedStateCheckChanges)
         return True
     # Replace if there was
     oldMod = self.oldModInfo.toModule()
     if oldMod is None:
         return False
     fit.modules.free(self.position)
     fit.modules.replace(self.position, oldMod)
     if oldMod not in fit.modules:
         pyfalog.warning('Failed to replace in list')
         self.Do()
         return False
     restoreCheckedStates(fit, self.savedStateCheckChanges)
     return True
Example #6
0
 def Undo(self):
     pyfalog.debug('Undoing cloning of local module from position {} to position {} for fit ID {}'.format(self.srcPosition, self.dstPosition, self.fitID))
     from .localRemove import CalcRemoveLocalModulesCommand
     cmd = CalcRemoveLocalModulesCommand(fitID=self.fitID, positions=[self.dstPosition])
     if not cmd.Do():
         return False
     restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
     return True
Example #7
0
 def Undo(self):
     pyfalog.debug('Undoing change of local module states at position {}/{} to click {} on fit {}'.format(self.mainPosition, self.positions, self.click, self.fitID))
     fit = Fit.getInstance().getFit(self.fitID)
     for position, state in self.savedStates.items():
         mod = fit.modules[position]
         pyfalog.debug('Reverting {} to state {} for fit ID {}'.format(mod, state, self.fitID))
         mod.state = state
     restoreCheckedStates(fit, self.savedStateCheckChanges, ignoreModPoss=self.savedStates)
     return True
Example #8
0
 def Undo(self):
     pyfalog.debug('Undoing change of projected module state at positions {} to state {} on fit {}'.format(
         self.positions, self.proposedState, self.fitID))
     fit = Fit.getInstance().getFit(self.fitID)
     for position, state in self.savedStates.items():
         mod = fit.projectedModules[position]
         pyfalog.debug('Reverting projected {} to state {} for fit ID {}'.format(mod, state, self.fitID))
         mod.state = state
     restoreCheckedStates(fit, self.savedStateCheckChanges)
     return True
Example #9
0
 def Undo(self):
     pyfalog.debug('Undoing change of local module states at position {}/{} to click {} on fit {}'.format(self.mainPosition, self.positions, self.click, self.fitID))
     fit = Fit.getInstance().getFit(self.fitID)
     for position, state in self.savedStates.items():
         mod = fit.modules[position]
         pyfalog.debug('Reverting {} to state {} for fit ID {}'.format(mod, state, self.fitID))
         mod.state = state
     restoreCheckedStates(fit, self.savedStateCheckChanges, ignoreModPoss=self.savedStates)
     eos.db.commit()
     return True
Example #10
0
 def Undo(self):
     pyfalog.debug('Undoing change of module charges according to map {} on fit {}'.format(self.chargeMap, self.fitID))
     cmd = CalcChangeModuleChargesCommand(
         fitID=self.fitID,
         projected=self.projected,
         chargeMap=self.savedChargeMap,
         ignoreRestriction=True)
     if not cmd.Do():
         return False
     restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
     return True
Example #11
0
 def Undo(self):
     pyfalog.debug(
         'Undoing change of projected module projection range at position {} to range {} on fit {}'
         .format(self.position, self.projectionRange, self.fitID))
     cmd = CalcChangeProjectedModuleProjectionRangeCommand(
         fitID=self.fitID,
         position=self.position,
         projectionRange=self.savedProjectionRange)
     result = cmd.Do()
     restoreCheckedStates(Fit.getInstance().getFit(self.fitID),
                          self.savedStateCheckChanges)
     return result
Example #12
0
 def Undo(self):
     pyfalog.debug('Undoing removal of projected module {} on fit {}'.format(self.savedModInfo, self.fitID))
     from .projectedAdd import CalcAddProjectedModuleCommand
     cmd = CalcAddProjectedModuleCommand(
         fitID=self.fitID,
         modInfo=self.savedModInfo,
         position=self.position,
         ignoreRestrictions=True)
     if not cmd.Do():
         return False
     restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
     return True
Example #13
0
 def Undo(self):
     pyfalog.debug(
         'Undoing change of projected fit {} range to {} for fit {}'.format(
             self.projectedFitID, self.projectionRange, self.fitID))
     cmd = CalcChangeProjectedFitProjectionRangeCommand(
         fitID=self.fitID,
         projectedFitID=self.projectedFitID,
         projectionRange=self.savedProjectionRange)
     result = cmd.Do()
     restoreCheckedStates(Fit.getInstance().getFit(self.fitID),
                          self.savedStateCheckChanges)
     return result
Example #14
0
 def Undo(self):
     pyfalog.debug('Undoing change of projected module state at positions {} to state {} on fit {}'.format(
         self.positions, self.proposedState, self.fitID))
     fit = Fit.getInstance().getFit(self.fitID)
     for position, state in self.savedStates.items():
         mod = fit.projectedModules[position]
         pyfalog.debug('Reverting projected {} to state {} for fit ID {}'.format(mod, state, self.fitID))
         mod.state = state
     restoreCheckedStates(fit, self.savedStateCheckChanges)
     if self.commit:
         eos.db.commit()
     return True
Example #15
0
 def Undo(self):
     pyfalog.debug('Undoing addition of local module {} to fit {}'.format(self.newModInfo, self.fitID))
     # We added a subsystem module, which actually ran the replace command. Run the undo for that guy instead
     if self.subsystemCmd is not None:
         return self.subsystemCmd.Undo()
     if self.savedPosition is None:
         return False
     from .localRemove import CalcRemoveLocalModuleCommand
     cmd = CalcRemoveLocalModuleCommand(fitID=self.fitID, positions=[self.savedPosition], commit=self.commit)
     if not cmd.Do():
         return False
     restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
     return True
Example #16
0
 def Undo(self):
     pyfalog.debug(
         'Undoing change of module charges according to map {} on fit {}'.
         format(self.chargeMap, self.fitID))
     cmd = CalcChangeModuleChargesCommand(fitID=self.fitID,
                                          projected=self.projected,
                                          chargeMap=self.savedChargeMap,
                                          ignoreRestriction=True)
     if not cmd.Do():
         return False
     restoreCheckedStates(Fit.getInstance().getFit(self.fitID),
                          self.savedStateCheckChanges)
     return True
Example #17
0
 def Undo(self):
     pyfalog.debug(
         'Undoing changing of projected fit {} state to {} for fit {}'.
         format(self.projectedFitID, self.state, self.fitID))
     cmd = CalcChangeProjectedFitStateCommand(
         fitID=self.fitID,
         projectedFitID=self.projectedFitID,
         state=self.savedState)
     if not cmd.Do():
         return False
     restoreCheckedStates(Fit.getInstance().getFit(self.fitID),
                          self.savedStateCheckChanges)
     return True
Example #18
0
 def Undo(self):
     pyfalog.debug(
         'Undoing removal of projected module {} on fit {}'.format(
             self.savedModInfo, self.fitID))
     from .projectedAdd import CalcAddProjectedModuleCommand
     cmd = CalcAddProjectedModuleCommand(fitID=self.fitID,
                                         modInfo=self.savedModInfo,
                                         position=self.position,
                                         ignoreRestrictions=True)
     if not cmd.Do():
         return False
     restoreCheckedStates(Fit.getInstance().getFit(self.fitID),
                          self.savedStateCheckChanges)
     return True
Example #19
0
 def Undo(self):
     pyfalog.debug('Undoing addition of local module {} to fit {}'.format(self.newModInfo, self.fitID))
     # We added a subsystem module, which actually ran the replace command. Run the undo for that guy instead
     if self.subsystemCmd is not None:
         if not self.subsystemCmd.Undo():
             return False
         restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
         return True
     if self.savedPosition is None:
         return False
     from .localRemove import CalcRemoveLocalModulesCommand
     cmd = CalcRemoveLocalModulesCommand(fitID=self.fitID, positions=[self.savedPosition])
     if not cmd.Do():
         return False
     restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
     return True
Example #20
0
 def Undo(self):
     pyfalog.debug('Undoing removal of projected fit {} for fit {}'.format(self.projectedFitID, self.fitID))
     if self.changeAmountCommand is not None:
         if not self.changeAmountCommand.Undo():
             return False
         restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
         return True
     from .add import CalcAddProjectedFitCommand
     cmd = CalcAddProjectedFitCommand(
         fitID=self.fitID,
         projectedFitID=self.projectedFitID,
         amount=self.savedAmount,
         state=self.savedState)
     if not cmd.Do():
         return False
     restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
     return True
Example #21
0
 def Undo(self):
     pyfalog.debug('Undoing removal of local modules {} on fit {}'.format(
         self.savedModInfos, self.fitID))
     results = []
     from .localReplace import CalcReplaceLocalModuleCommand
     for position, modInfo in self.savedModInfos.items():
         cmd = CalcReplaceLocalModuleCommand(fitID=self.fitID,
                                             position=position,
                                             newModInfo=modInfo,
                                             commit=False)
         results.append(cmd.Do())
     if not any(results):
         return False
     restoreCheckedStates(Fit.getInstance().getFit(self.fitID),
                          self.savedStateCheckChanges)
     if self.commit:
         eos.db.commit()
     return True
Example #22
0
 def Undo(self):
     pyfalog.debug('Undoing addition of projected fit {} for fit {}'.format(self.projectedFitID, self.fitID))
     if self.changeAmountCommand is not None:
         if not self.changeAmountCommand.Undo():
             return False
         restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
         return True
     # Can't find the projected fit, it must have been deleted. Just skip, as deleted fit
     # means that someone else just did exactly what we wanted to do
     projectedFit = Fit.getInstance().getFit(self.projectedFitID, projected=True)
     if projectedFit is not None:
         from .remove import CalcRemoveProjectedFitCommand
         cmd = CalcRemoveProjectedFitCommand(
             fitID=self.fitID,
             projectedFitID=self.projectedFitID,
             amount=self.amount)
         if not cmd.Do():
             return False
     restoreCheckedStates(Fit.getInstance().getFit(self.fitID), self.savedStateCheckChanges)
     return True
Example #23
0
 def Undo(self):
     pyfalog.debug(
         'Undoing replacement of local module at position {} to {} on fit {}'
         .format(self.newModInfo, self.position, self.fitID))
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     # Remove if there was no module
     if self.oldModInfo is None:
         from .localRemove import CalcRemoveLocalModuleCommand
         cmd = CalcRemoveLocalModuleCommand(fitID=self.fitID,
                                            positions=[self.position],
                                            commit=self.commit)
         if not cmd.Do():
             return False
         sFit.recalc(fit)
         restoreCheckedStates(fit, self.savedStateCheckChanges)
         return True
     # Replace if there was
     oldMod = self.oldModInfo.toModule()
     if oldMod is None:
         return False
     fit.modules.free(self.position)
     if not oldMod.fits(fit):
         pyfalog.warning('Module does not fit')
         self.Do()
         return False
     oldMod.owner = fit
     try:
         fit.modules.replace(self.position, oldMod)
     except HandledListActionError:
         pyfalog.warning('Failed to replace in list')
         self.Do()
         return False
     sFit.recalc(fit)
     restoreCheckedStates(fit, self.savedStateCheckChanges)
     if self.commit:
         eos.db.commit()
     return True
Example #24
0
 def Undo(self):
     pyfalog.debug('Undoing replacement of local module at position {} to {} on fit {}'.format(self.position, self.newModInfo, self.fitID))
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     # Remove if there was no module
     if self.oldModInfo is None:
         from .localRemove import CalcRemoveLocalModulesCommand
         cmd = CalcRemoveLocalModulesCommand(fitID=self.fitID, positions=[self.position])
         if not cmd.Do():
             return False
         restoreCheckedStates(fit, self.savedStateCheckChanges)
         return True
     # Replace if there was
     oldMod = self.oldModInfo.toModule()
     if oldMod is None:
         return False
     fit.modules.free(self.position)
     fit.modules.replace(self.position, oldMod)
     if oldMod not in fit.modules:
         pyfalog.warning('Failed to replace in list')
         self.Do()
         return False
     restoreCheckedStates(fit, self.savedStateCheckChanges)
     return True