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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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