Issue #2073: Added mechanism to pass implant list to implant set manager
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -14,6 +14,7 @@ class ImplantSetLoad(ContextMenuUnconditional):
|
||||
|
||||
if len(implantSets) == 0:
|
||||
return False
|
||||
|
||||
return srcContext in ("implantItemMisc", "implantEditor")
|
||||
|
||||
def getText(self, callingWindow, itmContext):
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user