Issue #2073: Added mechanism to pass implant list to implant set manager

This commit is contained in:
Gochim
2019-12-10 08:50:21 +02:00
parent f55ab00bf5
commit d92e11893a
4 changed files with 11 additions and 30 deletions

View File

@@ -14,39 +14,16 @@ class ImplantSetAdd(ContextMenuUnconditional):
if len(implantSets) == 0:
return False
return srcContext in ("implantSetAdd", "implantEditor")
def getText(self, callingWindow, itmContext):
return "Add As New Implant Set"
def getSubMenu(self, callingWindow, context, rootMenu, i, pitem):
m = wx.Menu()
bindmenu = rootMenu if "wxMSW" in wx.PlatformInfo else m
def activate(self, callingWindow, fullContext, i):
sIS = s_ImplantSets.getInstance()
implantSets = sIS.getImplantSetList()
self.context = context
self.callingWindow = callingWindow
self.idmap = {}
for set in sorted(implantSets, key=lambda i: i.name):
id = ContextMenuUnconditional.nextID()
mitem = wx.MenuItem(rootMenu, id, set.name)
bindmenu.Bind(wx.EVT_MENU, self.handleSelection, mitem)
self.idmap[id] = set
m.Append(mitem)
return m
def handleSelection(self, event):
impSet = self.idmap.get(event.Id, None)
if impSet is None:
event.Skip()
return
self.callingWindow.addImplantSet(impSet)
callingWindow.mainFrame.OnShowImplantSetEditor(None, implantSets)
ImplantSetAdd.register()

View File

@@ -14,6 +14,7 @@ class ImplantSetLoad(ContextMenuUnconditional):
if len(implantSets) == 0:
return False
return srcContext in ("implantItemMisc", "implantEditor")
def getText(self, callingWindow, itmContext):

View File

@@ -442,8 +442,8 @@ class MainFrame(wx.Frame):
def OnShowDamagePatternEditor(self, event):
DmgPatternEditor.openOne(parent=self)
def OnShowImplantSetEditor(self, event):
ImplantSetEditor.openOne(parent=self)
def OnShowImplantSetEditor(self, event, dataToAdd=None):
ImplantSetEditor.openOne(parent=self, dataToAdd=dataToAdd)
def OnShowExportDialog(self, event):
""" Export active fit """

View File

@@ -117,7 +117,7 @@ class ImplantSetEditorView(BaseImplantEditorView):
class ImplantSetEditor(AuxiliaryFrame):
def __init__(self, parent):
def __init__(self, parent, dataToAdd=None):
super().__init__(
parent, id=wx.ID_ANY, title="Implant Set Editor", resizeable=True,
size=wx.Size(950, 500) if "wxGTK" in wx.PlatformInfo else wx.Size(850, 420))
@@ -166,7 +166,10 @@ class ImplantSetEditor(AuxiliaryFrame):
self.SetSizer(mainSizer)
self.Layout()
if not self.entityEditor.checkEntitiesExist():
if dataToAdd:
# add elements passed from outside
pass
elif not self.entityEditor.checkEntitiesExist():
self.Close()
return