structureProfiles.py (5512B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\structure\structureBrowser\structureProfiles.py 2 from carbonui.primitives.container import Container 3 from carbonui.primitives.containerAutoSize import ContainerAutoSize 4 from carbonui.util.bunch import Bunch 5 from carbonui.util.sortUtil import SortListOfTuples 6 from eve.client.script.ui.control.eveLabel import EveLabelMedium, EveLabelLarge 7 from eve.client.script.ui.control.eveScroll import Scroll 8 from eve.client.script.ui.control.infoIcon import MoreInfoIcon 9 from eve.client.script.ui.control.themeColored import FillThemeColored 10 from eve.client.script.ui.structure import ChangeSignalConnect 11 from eve.client.script.ui.structure.accessGroups.addCont import AddCont 12 from eve.client.script.ui.structure.structureBrowser.browserUIConst import ALL_PROFILES 13 from eve.client.script.ui.structure.structureBrowser.nameAndDescriptionWnd import CreateProfileWnd 14 from eve.client.script.ui.structure.structureBrowser.entries.structureProfileEntry import StructureProfileEntry, StructureAllProfilesEntry 15 from eve.client.script.ui.structure.structureSettings.controllers.slimProfileController import SlimStructureProfileController, SlimStructureAllProfilesController 16 from localization import GetByLabel 17 import log 18 from utillib import KeyVal 19 import carbonui.const as uiconst 20 21 class StructureProfiles(Container): 22 explanationLabelPath = 'UI/StructureProfiles/ProfileHint' 23 24 def ApplyAttributes(self, attributes): 25 Container.ApplyAttributes(self, attributes) 26 self.allStructuresProfileController = attributes.allStructuresProfileController 27 self.structureBrowserController = attributes.structureBrowserController 28 self.ChangeSignalConnection(connect=True) 29 self.AddHeader() 30 self.addCont = AddProfileCont(parent=self, padTop=4, controller=self.allStructuresProfileController, padBottom=2, height=32) 31 self.scroll = Scroll(name='structureProfileScroll', parent=self, padTop=2) 32 self.scroll.multiSelect = False 33 self.LoadProfileList() 34 35 def ChangeSignalConnection(self, connect = True): 36 signalAndCallback = [(self.allStructuresProfileController.on_profile_saved, self.OnProfileSaved), (self.structureBrowserController.on_profile_deleted, self.OnProfileDeleted), (self.structureBrowserController.on_default_profile_set, self.OnDefaultChanged)] 37 ChangeSignalConnect(signalAndCallback, connect) 38 39 def AddHeader(self): 40 headerCont = Container(name='headerCont', parent=self, align=uiconst.TOTOP, height=32, clipChildren=True) 41 FillThemeColored(parent=headerCont, padBottom=1, colorType=uiconst.COLORTYPE_UIHILIGHT) 42 text = GetByLabel('UI/StructureProfiles/StructureProfiles') 43 cont = ContainerAutoSize(name='textCont', parent=headerCont, align=uiconst.TOLEFT) 44 EveLabelLarge(text=text, parent=cont, left=8, state=uiconst.UI_DISABLED, maxLines=1, align=uiconst.CENTERLEFT) 45 cont = ContainerAutoSize(name='textCont', parent=headerCont, align=uiconst.TOLEFT, padLeft=6) 46 MoreInfoIcon(parent=cont, hint=GetByLabel(self.explanationLabelPath), align=uiconst.CENTERLEFT) 47 48 def LoadProfileList(self, force = False): 49 selectedProfileID = self.structureBrowserController.GetSelectedProfileID() 50 profileControllers = self.allStructuresProfileController.GetProfiles(force=force) 51 scrollList = [] 52 for profileID, eachProfileController in profileControllers.iteritems(): 53 nodeData = Bunch(decoClass=StructureProfileEntry, profileController=eachProfileController, allStructuresProfileController=self.allStructuresProfileController, structureBrowserController=self.structureBrowserController, isSelected=profileID == selectedProfileID) 54 sortValue = eachProfileController.GetProfileName().lower() 55 scrollList.append((sortValue, nodeData)) 56 57 scrollList = SortListOfTuples(scrollList) 58 anyProfileText = GetByLabel('UI/Structures/Browser/AnyProfile') 59 anyProfileDesc = GetByLabel('UI/StructureProfiles/AnyProfileDesc') 60 controllerForShowAll = SlimStructureAllProfilesController(ALL_PROFILES, profileData=KeyVal(name=anyProfileText, description=anyProfileDesc, isDefault=None)) 61 nodeData = Bunch(decoClass=StructureAllProfilesEntry, profileController=controllerForShowAll, allStructuresProfileController=self.allStructuresProfileController, structureBrowserController=self.structureBrowserController, isSelected=ALL_PROFILES == selectedProfileID) 62 scrollList.insert(0, nodeData) 63 self.scroll.Load(contentList=scrollList) 64 65 def OnProfileSaved(self, profileID): 66 self.LoadProfileList() 67 68 def OnProfileDeleted(self, profileID, selectedProfileChanged): 69 self.LoadProfileList() 70 71 def OnDefaultChanged(self): 72 self.LoadProfileList(force=True) 73 74 def Close(self): 75 try: 76 self.ChangeSignalConnection(connect=False) 77 except Exception as e: 78 log.LogError('Failed at closing struture profile, e = ', e) 79 finally: 80 Container.Close(self) 81 82 83 class AddProfileCont(AddCont): 84 default_name = 'AddGroupCont' 85 tooltipPath = 'UI/Structures/AccessGroups/CreateNewGroup' 86 87 def ApplyAttributes(self, attributes): 88 AddCont.ApplyAttributes(self, attributes) 89 self.createNewLabel.text = GetByLabel('UI/StructureProfiles/NewProfile') 90 91 def OnAddEntry(self, *args): 92 CreateProfileWnd.Open(controller=self.controller)