Issue #2073: Added functionality to add all implants in fit implant tab to implant set list
This commit is contained in:
@@ -1,18 +1,15 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
from gui.contextMenu import ContextMenuUnconditional
|
||||
from service.implantSet import ImplantSets as s_ImplantSets
|
||||
|
||||
|
||||
class ImplantSetAdd(ContextMenuUnconditional):
|
||||
|
||||
def display(self, callingWindow, srcContext):
|
||||
|
||||
sIS = s_ImplantSets.getInstance()
|
||||
implantSets = sIS.getImplantSetList()
|
||||
if not hasattr(callingWindow, 'implants'):
|
||||
return False
|
||||
|
||||
if len(implantSets) == 0:
|
||||
implantList = callingWindow.implants
|
||||
if not implantList or len(implantList) == 0:
|
||||
return False
|
||||
|
||||
return srcContext in ("implantSetAdd", "implantEditor")
|
||||
@@ -21,9 +18,8 @@ class ImplantSetAdd(ContextMenuUnconditional):
|
||||
return "Add As New Implant Set"
|
||||
|
||||
def activate(self, callingWindow, fullContext, i):
|
||||
sIS = s_ImplantSets.getInstance()
|
||||
implantSets = sIS.getImplantSetList()
|
||||
callingWindow.mainFrame.OnShowImplantSetEditor(None, implantSets)
|
||||
implantList = callingWindow.implants
|
||||
callingWindow.mainFrame.OnShowImplantSetEditor(None, implantList)
|
||||
|
||||
|
||||
ImplantSetAdd.register()
|
||||
|
||||
@@ -178,10 +178,17 @@ class EntityEditor(wx.Panel):
|
||||
return True
|
||||
|
||||
def checkEntitiesExist(self):
|
||||
if len(self.choices) == 0:
|
||||
self.Parent.Hide()
|
||||
if self.OnNew(None) is False:
|
||||
return False
|
||||
self.Parent.Show()
|
||||
if len(self.choices) > 0:
|
||||
return True
|
||||
else:
|
||||
return self.enterNewEntity()
|
||||
|
||||
def enterNewEntity(self):
|
||||
self.Parent.Hide()
|
||||
if self.OnNew(None) is False:
|
||||
return False
|
||||
self.Parent.Show()
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
||||
@@ -84,6 +84,14 @@ class ImplantSetEntityEditor(EntityEditor):
|
||||
sIS = ImplantSets.getInstance()
|
||||
sIS.deleteSet(entity)
|
||||
|
||||
def addExternalDataToSet(self, dataToAdd):
|
||||
""" Add new set and fill it with data from the current fit """
|
||||
if self.enterNewEntity():
|
||||
sIS = ImplantSets.getInstance()
|
||||
set_ = self.Parent.entityEditor.getActiveEntity()
|
||||
for item in dataToAdd:
|
||||
sIS.addImplant(set_.ID, item.item.ID)
|
||||
|
||||
|
||||
class ImplantSetEditorView(BaseImplantEditorView):
|
||||
|
||||
@@ -167,8 +175,8 @@ class ImplantSetEditor(AuxiliaryFrame):
|
||||
self.Layout()
|
||||
|
||||
if dataToAdd:
|
||||
# add elements passed from outside
|
||||
pass
|
||||
# add an implant set using data passed from outside
|
||||
self.entityEditor.addExternalDataToSet(dataToAdd)
|
||||
elif not self.entityEditor.checkEntitiesExist():
|
||||
self.Close()
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user