sharesPanel.py (3336B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\neocom\wallet\panels\sharesPanel.py 2 from carbon.common.script.util.format import FmtAmt 3 from carbonui.primitives.container import Container 4 from eve.client.script.ui.control.entries.generic import Generic 5 from eve.client.script.ui.control.entries.util import GetFromClass 6 from eve.client.script.ui.control.eveScroll import Scroll 7 from eve.client.script.ui.shared.neocom.wallet.panels.sharesUtil import GetSharesMenu 8 from eve.client.script.ui.shared.neocom.wallet.walletConst import WALLET_SHARES_SCROLLID 9 from eve.common.lib import appConst 10 from localization import GetByLabel 11 headers = (GetByLabel('UI/Wallet/WalletWindow/ColHeaderOwner'), GetByLabel('UI/Wallet/WalletWindow/ColHeaderCorporation'), GetByLabel('UI/Wallet/WalletWindow/ColHeaderShares')) 12 13 class SharesPanel(Container): 14 default_name = 'SharesPanel' 15 __notifyevents__ = ['OnShareChange'] 16 17 def ApplyAttributes(self, attributes): 18 super(SharesPanel, self).ApplyAttributes(attributes) 19 sm.RegisterNotify(self) 20 self.scroll = Scroll(parent=self) 21 self.scroll.sr.id = WALLET_SHARES_SCROLLID 22 23 def OnTabSelect(self): 24 self.ShowMyShares() 25 26 def ShowMyShares(self): 27 if self.IsAccessDenied(): 28 self.SetHint(GetByLabel('UI/Wallet/WalletWindow/HintNeedAccountant')) 29 elif self.IsCorpWallet() and not (appConst.corpRoleAccountant | appConst.corpRoleJuniorAccountant) & session.corprole != 0: 30 self.scroll.Clear() 31 self.SetHint(GetByLabel('UI/Wallet/WalletWindow/HintNeedAccountantRoles')) 32 else: 33 self.PopulateScroll() 34 35 def PopulateScroll(self): 36 scrolllist = self.GetScrollList() 37 if scrolllist: 38 self.scroll.Load(fixedEntryHeight=24, contentList=scrolllist, headers=headers) 39 else: 40 self.scroll.Clear() 41 if self.IsCorpWallet(): 42 self.scroll.ShowHint(GetByLabel('UI/Wallet/WalletWindow/HintNoCorpShares')) 43 else: 44 self.scroll.ShowHint(GetByLabel('UI/Wallet/WalletWindow/HintNoShares')) 45 46 def GetScrollList(self): 47 scrolllist = [] 48 shares = sm.GetService('corp').GetSharesByShareholder(self.IsCorpWallet()) 49 for share in shares.itervalues(): 50 entry = self.GetEntry(share) 51 scrolllist.append(entry) 52 53 return scrolllist 54 55 def GetEntry(self, shareCertificate): 56 ownerID = self.GetOwnerID() 57 corporationID = shareCertificate.corporationID 58 shares = shareCertificate.shares 59 return GetFromClass(Generic, {'ownerID': ownerID, 60 'corporationID': corporationID, 61 'shares': shares, 62 'GetMenu': GetSharesMenu, 63 'label': [cfg.eveowners.Get(ownerID).name, 64 '<t>', 65 cfg.eveowners.Get(corporationID).name, 66 '<t>', 67 FmtAmt(shares)]}) 68 69 def IsAccessDenied(self): 70 return False 71 72 def OnShareChange(self, shareholderID, corporationID, change): 73 if self.GetOwnerID() in (shareholderID, corporationID) and self.display: 74 self.ShowMyShares() 75 76 def GetOwnerID(self): 77 raise NotImplementedError 78 79 def IsCorpWallet(self): 80 raise NotImplementedError