PluginProjectDjango.py

changeset 12
430932e3094c
parent 11
5eda53fad138
child 20
09e9084796de
equal deleted inserted replaced
11:5eda53fad138 12:430932e3094c
147 147
148 self.__mainAct = None 148 self.__mainAct = None
149 self.__mainMenu = None 149 self.__mainMenu = None
150 150
151 self.__e5project = e5App().getObject("Project") 151 self.__e5project = e5App().getObject("Project")
152
153 self.__supportedVariants = []
152 154
153 def __checkVersions(self): 155 def __checkVersions(self):
154 """ 156 """
155 Private function to check that the eric5 version is ok. 157 Private function to check that the eric5 version is ok.
156 158
183 self.__object.initActions() 185 self.__object.initActions()
184 e5App().registerPluginObject("ProjectDjango", self.__object) 186 e5App().registerPluginObject("ProjectDjango", self.__object)
185 187
186 self.__mainMenu = self.__object.initMenu() 188 self.__mainMenu = self.__object.initMenu()
187 189
188 try: 190 self.__supportedVariants = self.__object.supportedPythonVariants()
189 self.__e5project.registerProjectType("Django", self.trUtf8("Django"), 191
190 self.fileTypesCallback, 192 if self.__supportedVariants:
191 lexerAssociationCallback=self.lexerAssociationCallback, 193 try:
192 binaryTranslationsCallback=self.binaryTranslationsCallback, 194 self.__e5project.registerProjectType("Django", self.trUtf8("Django"),
193 progLanguages=["Python2", "Python3"]) 195 self.fileTypesCallback,
194 except TypeError: 196 lexerAssociationCallback=self.lexerAssociationCallback,
195 # for backward compatibility 197 binaryTranslationsCallback=self.binaryTranslationsCallback,
196 self.__e5project.registerProjectType("Django", self.trUtf8("Django"), 198 progLanguages=self.__supportedVariants[:])
197 self.fileTypesCallback, 199 except TypeError:
198 lexerAssociationCallback=self.lexerAssociationCallback, 200 # for backward compatibility
199 binaryTranslationsCallback=self.binaryTranslationsCallback) 201 self.__e5project.registerProjectType("Django", self.trUtf8("Django"),
202 self.fileTypesCallback,
203 lexerAssociationCallback=self.lexerAssociationCallback,
204 binaryTranslationsCallback=self.binaryTranslationsCallback)
200 205
201 from Project.ProjectBrowser import SourcesBrowserFlag, FormsBrowserFlag, \ 206 from Project.ProjectBrowser import SourcesBrowserFlag, FormsBrowserFlag, \
202 TranslationsBrowserFlag, OthersBrowserFlag 207 TranslationsBrowserFlag, OthersBrowserFlag
203 Preferences.setProjectBrowserFlagsDefault("Django", 208 Preferences.setProjectBrowserFlagsDefault("Django",
204 SourcesBrowserFlag | \ 209 SourcesBrowserFlag | \
364 @param key the key of the setting to be set (string) 369 @param key the key of the setting to be set (string)
365 @param value the value to be set 370 @param value the value to be set
366 @param prefClass preferences class used as the storage area 371 @param prefClass preferences class used as the storage area
367 """ 372 """
368 Preferences.Prefs.settings.setValue(self.PreferencesKey + "/" + key, value) 373 Preferences.Prefs.settings.setValue(self.PreferencesKey + "/" + key, value)
374
375 if key in ["VirtualEnvironmentPy2", "VirtualEnvironmentPy3"]:
376 self.__reregisterProjectType()
377
378 def __reregisterProjectType(self):
379 """
380 Private method to re-register the project type.
381 """
382 supportedVariants = self.__object.supportedPythonVariants()
383 if supportedVariants != self.__supportedVariants:
384 # step 1: unregister
385 self.__e5project.unregisterProjectType("Django")
386
387 # step 2: register again with new language settings
388 self.__supportedVariants = supportedVariants
389 if self.__supportedVariants:
390 try:
391 self.__e5project.registerProjectType("Django", self.trUtf8("Django"),
392 self.fileTypesCallback,
393 lexerAssociationCallback=self.lexerAssociationCallback,
394 binaryTranslationsCallback=self.binaryTranslationsCallback,
395 progLanguages=self.__supportedVariants[:])
396 except TypeError:
397 # for backward compatibility
398 self.__e5project.registerProjectType("Django", self.trUtf8("Django"),
399 self.fileTypesCallback,
400 lexerAssociationCallback=self.lexerAssociationCallback,
401 binaryTranslationsCallback=self.binaryTranslationsCallback)

eric ide

mercurial