示例#1
0
    def SmartAnalyse(self, interpreter):
        if interpreter.IsBuiltIn:
            return
        try:
            interpreter.GetDocPath()
            interpreter.GetSysPathList()
            interpreter.GetBuiltins()
            self.package_panel.LoadPackages(interpreter, True)
        except Exception as e:
            wx.MessageBox(str(e), style=wx.OK | wx.ICON_ERROR)
            return
        self.path_panel.AppendSysPath(interpreter)
        self.builtin_panel.SetBuiltiins(interpreter)
        self.smart_analyse_btn.Enable(False)

        dlg = AnalyseProgressDialog(self)
        try:
            intellisence.IntellisenceManager().generate_intellisence_data(
                interpreter, dlg)
        except:
            return
        while True:
            if not dlg.KeepGoing:
                break
            wx.MilliSleep(250)
            wx.Yield()
            dlg.Pulse()

        dlg.Destroy()
        self.smart_analyse_btn.Enable(True)
示例#2
0
 def OnChar(self,event):
     if self.CallTipActive():
         self.CallTipCancel()
     key = event.GetKeyCode()
     pos = self.GetCurrentPos()
     # Tips
     if key == ord("("):
         #delete selected text
         if self.GetSelectedText():
             self.ReplaceSelection("")
         self.AddText("(")
         self.GetArgTip(pos)
     elif key == ord(self.TYPE_POINT_WORD):
         #delete selected text
         if self.GetSelectedText():
             self.ReplaceSelection("")
         self.AddText(self.TYPE_POINT_WORD)
         self.ListMembers(pos)
     elif key == ord(self.TYPE_BLANK_WORD):
         if self.GetSelectedText():
             self.ReplaceSelection("")
         self.AddText(self.TYPE_BLANK_WORD)
         is_from_import_type,name = self.IsFromImportType(pos)
         if is_from_import_type:
             member_list = intellisence.IntellisenceManager().GetMemberList(name)
             if member_list == []:
                 return
             member_list.insert(0,"*")
             self.AutoCompShow(0, string.join(member_list))
         elif self.IsImportType(pos) or self.IsFromType(pos):
             import_list = intellisence.IntellisenceManager().GetImportList()
             import_list.extend(self.GetCurdirImports())
             import_list.sort(parserutils.CmpMember)
             if import_list == []:
                 return
             self.AutoCompShow(0, string.join(import_list))
         elif self.IsFromModuleType(pos):
             self.AutoCompShow(0, string.join([self.TYPE_IMPORT_WORD]))
     else:
         event.Skip()
示例#3
0
    def GetAutoCompleteKeywordList(self, context, hint, line):
        obj = None
        try:
            if context and len(context):
                obj = eval(context, globals(), locals())
        except:
            if not hint or len(
                    hint) == 0:  # context isn't valid, maybe it was the hint
                hint = context

        if obj is None:
            kw = keyword.kwlist[:]
            module_scope = self.ModuleScope
            members = []
            if module_scope is not None:
                scope = module_scope.FindScope(line)
                parent = scope
                while parent is not None:
                    if parent.Parent is None:
                        members.extend(parent.GetMembers())
                    else:
                        members.extend(parent.GetMemberList(False))
                    parent = parent.Parent
                kw.extend(members)
                builtin_members = intellisence.IntellisenceManager(
                ).GetBuiltinModuleMembers()
                kw.extend(builtin_members)
        else:
            symTbl = dir(obj)
            kw = filter(lambda item: item[0] != '_',
                        symTbl)  # remove local variables and methods

        if hint and len(hint):
            lowerHint = hint.lower()
            filterkw = filter(
                lambda item: item.lower().startswith(lowerHint),
                kw)  # remove variables and methods that don't match hint
            kw = filterkw

        kw.sort(CmpMember)
        if hint:
            replaceLen = len(hint)
        else:
            replaceLen = 0
        return " ".join(kw), replaceLen
示例#4
0
文件: IDE.py 项目: ver007/NovalIDE
    def OnInit(self):
        global ACTIVEGRID_BASE_IDE
        global USE_OLD_PROJECTS
        args = sys.argv

        #init ide logger
        log_mode = logger.LOG_MODE_IDE

        # Suppress non-fatal errors that might prompt the user even in cases
        # when the error does not impact them.
        #the log will redirect to NovalIDE.exe.log when convert into windows exe with py2exe
        wx.Log_SetActiveTarget(AppLog())
        if "-h" in args or "-help" in args or "--help" in args\
            or (wx.Platform == "__WXMSW__" and "/help" in args):
            print "Usage: ActiveGridAppBuilder.py [options] [filenames]\n"
            # Mac doesn't really support multiple instances for GUI apps
            # and since we haven't got time to test this thoroughly I'm
            # disabling it for now.
            if wx.Platform != "__WXMAC__":
                print "    option " + printArg(
                    "multiple"
                ) + " to allow multiple instances of application."
            print "    option " + printArg("debug") + " for debug mode."
            print "    option '-h' or " + printArg(
                "help") + " to show usage information for command."
            print "    option " + printArg("baseide") + " for base IDE mode."
            print "    [filenames] is an optional list of files you want to open when application starts."
            return False
        elif isInArgs("dev", args):
            self.SetAppName(_("NovalBuilderDev"))
            self.SetDebug(False)
        elif isInArgs("debug", args):
            self.SetAppName(_("NovalBuilderDebug"))
            self.SetDebug(True)
            ACTIVEGRID_BASE_IDE = True
            log_mode = logger.LOG_MODE_TESTRUN
            self.SetSingleInstance(False)
        elif isInArgs("baseide", args):
            self.SetAppName(_("NovalIDE"))
            ACTIVEGRID_BASE_IDE = True
        elif isInArgs("tools", args):
            USE_OLD_PROJECTS = True
        else:
            self.SetAppName(_("NovalBuilder"))
            self.SetDebug(False)
        if isInArgs("multiple", args) and wx.Platform != "__WXMAC__":
            self.SetSingleInstance(False)

        logger.initLogging(log_mode)

        if not wx.lib.pydocview.DocApp.OnInit(self):
            return False

        self.ShowSplash(getIDESplashBitmap())

        import STCTextEditor
        import TextService
        import FindInDirService
        import MarkerService
        import project as projectlib
        import ProjectEditor
        import PythonEditor
        import OutlineService
        import XmlEditor
        import HtmlEditor
        import TabbedView
        import MessageService
        ##  import OutputService
        import Service
        import ImageEditor
        import PerlEditor
        import PHPEditor
        import wx.lib.ogl as ogl
        import DebuggerService
        import AboutDialog
        import SVNService
        import ExtensionService
        import CompletionService
        import GeneralOption
        import NavigationService
        import TabbedFrame
        ##        import UpdateLogIniService

        _EDIT_LAYOUTS = True
        self._open_project_path = None

        # This creates some pens and brushes that the OGL library uses.
        # It should be called after the app object has been created, but
        # before OGL is used.
        ogl.OGLInitialize()

        config = wx.Config(self.GetAppName(), style=wx.CONFIG_USE_LOCAL_FILE)
        if not config.Exists(
                "MDIFrameMaximized"
        ):  # Make the initial MDI frame maximize as default
            config.WriteInt("MDIFrameMaximized", True)
        if not config.Exists(
                "MDIEmbedRightVisible"
        ):  # Make the properties embedded window hidden as default
            config.WriteInt("MDIEmbedRightVisible", False)

        ##my_locale must be set as app member property,otherwise it will only workable when app start up
        ##it will not workable after app start up,the translation also will not work
        lang_id = GeneralOption.GetLangId(config.Read("Language", ""))
        if wx.Locale.IsAvailable(lang_id):
            self.my_locale = wx.Locale(lang_id)
            if self.my_locale.IsOk():
                self.my_locale.AddCatalogLookupPathPrefix(
                    os.path.join(sysutilslib.mainModuleDir, 'noval', 'locale'))
                ibRet = self.my_locale.AddCatalog(self.GetAppName().lower())
                ibRet = self.my_locale.AddCatalog("wxstd")
                self.my_locale.AddCatalog("wxstock")

        docManager = IDEDocManager(flags=self.GetDefaultDocManagerFlags())
        self.SetDocumentManager(docManager)

        # Note:  These templates must be initialized in display order for the "Files of type" dropdown for the "File | Open..." dialog
        defaultTemplate = wx.lib.docview.DocTemplate(
            docManager,
            _("Any"),
            "*.*",
            _("Any"),
            _(".txt"),
            _("Text Document"),
            _("Text View"),
            STCTextEditor.TextDocument,
            STCTextEditor.TextView,
            wx.lib.docview.TEMPLATE_INVISIBLE,
            icon=STCTextEditor.getTextIcon())
        docManager.AssociateTemplate(defaultTemplate)

        htmlTemplate = wx.lib.docview.DocTemplate(
            docManager,
            _("HTML"),
            "*.html;*.htm",
            _("HTML"),
            _(".html"),
            _("HTML Document"),
            _("HTML View"),
            HtmlEditor.HtmlDocument,
            HtmlEditor.HtmlView,
            icon=HtmlEditor.getHTMLIcon())
        docManager.AssociateTemplate(htmlTemplate)

        imageTemplate = wx.lib.docview.DocTemplate(
            docManager,
            _("Image"),
            "*.bmp;*.ico;*.gif;*.jpg;*.jpeg;*.png",
            _("Image"),
            _(".png"),
            _("Image Document"),
            _("Image View"),
            ImageEditor.ImageDocument,
            ImageEditor.ImageView,
            wx.lib.docview.TEMPLATE_NO_CREATE,
            icon=ImageEditor.getImageIcon())
        docManager.AssociateTemplate(imageTemplate)

        perlTemplate = wx.lib.docview.DocTemplate(
            docManager,
            _("Perl"),
            "*.pl",
            _("Perl"),
            _(".pl"),
            _("Perl Document"),
            _("Perl View"),
            PerlEditor.PerlDocument,
            PerlEditor.PerlView,
            icon=PerlEditor.getPerlIcon())
        docManager.AssociateTemplate(perlTemplate)

        phpTemplate = wx.lib.docview.DocTemplate(docManager,
                                                 _("PHP"),
                                                 "*.php",
                                                 _("PHP"),
                                                 _(".php"),
                                                 _("PHP Document"),
                                                 _("PHP View"),
                                                 PHPEditor.PHPDocument,
                                                 PHPEditor.PHPView,
                                                 icon=PHPEditor.getPHPIcon())
        docManager.AssociateTemplate(phpTemplate)

        projectTemplate = ProjectEditor.ProjectTemplate(
            docManager,
            _("Project"),
            "*%s" % PROJECT_EXTENSION,
            _("Project"),
            _(PROJECT_EXTENSION),
            _("Project Document"),
            _("Project View"),
            ProjectEditor.ProjectDocument,
            ProjectEditor.ProjectView,
            ###   wx.lib.docview.TEMPLATE_NO_CREATE,
            icon=ProjectEditor.getProjectIcon())
        docManager.AssociateTemplate(projectTemplate)

        pythonTemplate = wx.lib.docview.DocTemplate(
            docManager,
            _("Python"),
            "*.py;*.pyw",
            _("Python"),
            _(".py"),
            _("Python Document"),
            _("Python View"),
            PythonEditor.PythonDocument,
            PythonEditor.PythonView,
            icon=PythonEditor.getPythonIcon())
        docManager.AssociateTemplate(pythonTemplate)

        textTemplate = wx.lib.docview.DocTemplate(
            docManager,
            _("Text"),
            "*.text;*.txt",
            _("Text"),
            _(".txt"),
            _("Text Document"),
            _("Text View"),
            STCTextEditor.TextDocument,
            STCTextEditor.TextView,
            icon=STCTextEditor.getTextIcon())
        docManager.AssociateTemplate(textTemplate)

        xmlTemplate = wx.lib.docview.DocTemplate(docManager,
                                                 _("XML"),
                                                 "*.xml",
                                                 _("XML"),
                                                 _(".xml"),
                                                 _("XML Document"),
                                                 _("XML View"),
                                                 XmlEditor.XmlDocument,
                                                 XmlEditor.XmlView,
                                                 icon=XmlEditor.getXMLIcon())
        docManager.AssociateTemplate(xmlTemplate)

        pythonService = self.InstallService(
            PythonEditor.PythonService(_("Python Interpreter"),
                                       embeddedWindowLocation=wx.lib.pydocview.
                                       EMBEDDED_WINDOW_BOTTOM))
        if not ACTIVEGRID_BASE_IDE:
            propertyService = self.InstallService(
                PropertyService.PropertyService(
                    "Properties",
                    embeddedWindowLocation=wx.lib.pydocview.
                    EMBEDDED_WINDOW_RIGHT))
        projectService = self.InstallService(
            ProjectEditor.ProjectService(_("Projects/Resources View"),
                                         embeddedWindowLocation=wx.lib.
                                         pydocview.EMBEDDED_WINDOW_TOPLEFT))
        findService = self.InstallService(FindInDirService.FindInDirService())
        if not ACTIVEGRID_BASE_IDE:
            webBrowserService = self.InstallService(
                WebBrowserService.WebBrowserService()
            )  # this must be before webServerService since it sets the proxy environment variable that is needed by the webServerService.
            webServerService = self.InstallService(
                WebServerService.WebServerService()
            )  # this must be after webBrowserService since that service sets the proxy environment variables.
        outlineService = self.InstallService(
            OutlineService.OutlineService(
                _("Outline"),
                embeddedWindowLocation=wx.lib.pydocview.
                EMBEDDED_WINDOW_BOTTOMLEFT))
        filePropertiesService = self.InstallService(
            wx.lib.pydocview.FilePropertiesService())
        markerService = self.InstallService(MarkerService.MarkerService())
        textService = self.InstallService(TextService.TextService())
        perlService = self.InstallService(PerlEditor.PerlService())
        phpService = self.InstallService(PHPEditor.PHPService())
        comletionService = self.InstallService(
            CompletionService.CompletionService())
        navigationService = self.InstallService(
            NavigationService.NavigationService())
        messageService = self.InstallService(
            MessageService.MessageService(_("Search Results"),
                                          embeddedWindowLocation=wx.lib.
                                          pydocview.EMBEDDED_WINDOW_BOTTOM))
        ##    outputService          = self.InstallService(OutputService.OutputService("Output", embeddedWindowLocation = wx.lib.pydocview.EMBEDDED_WINDOW_BOTTOM))
        debuggerService = self.InstallService(
            DebuggerService.DebuggerService("Debugger",
                                            embeddedWindowLocation=wx.lib.
                                            pydocview.EMBEDDED_WINDOW_BOTTOM))
        extensionService = self.InstallService(
            ExtensionService.ExtensionService())
        ###optionsService          = self.InstallService(wx.lib.pydocview.DocOptionsService(supportedModes=wx.lib.docview.DOC_MDI))
        optionsService = self.InstallService(
            GeneralOption.GeneralOptionsService())
        aboutService = self.InstallService(
            wx.lib.pydocview.AboutService(AboutDialog.AboutDialog))
        ###   svnService              = self.InstallService(SVNService.SVNService())
        if not ACTIVEGRID_BASE_IDE:
            helpPath = os.path.join(sysutilslib.mainModuleDir, "activegrid",
                                    "tool", "data", "AGDeveloperGuideWebHelp",
                                    "AGDeveloperGuideWebHelp.hhp")
            helpService = self.InstallService(
                HelpService.HelpService(helpPath))
        if self.GetUseTabbedMDI():
            windowService = self.InstallService(
                wx.lib.pydocview.WindowMenuService())

        # order of these added determines display order of Options Panels
        optionsService.AddOptionsPanel(ProjectEditor.ProjectOptionsPanel)
        ## optionsService.AddOptionsPanel(DebuggerService.DebuggerOptionsPanel)
        optionsService.AddOptionsPanel(PythonEditor.PythonOptionsPanel)
        ##      optionsService.AddOptionsPanel(PHPEditor.PHPOptionsPanel)
        ##    optionsService.AddOptionsPanel(PerlEditor.PerlOptionsPanel)
        optionsService.AddOptionsPanel(XmlEditor.XmlOptionsPanel)
        optionsService.AddOptionsPanel(HtmlEditor.HtmlOptionsPanel)
        optionsService.AddOptionsPanel(STCTextEditor.TextOptionsPanel)
        ##      optionsService.AddOptionsPanel(SVNService.SVNOptionsPanel)
        optionsService.AddOptionsPanel(ExtensionService.ExtensionOptionsPanel)

        filePropertiesService.AddCustomEventHandler(projectService)

        outlineService.AddViewTypeForBackgroundHandler(PythonEditor.PythonView)
        ###outlineService.AddViewTypeForBackgroundHandler(PHPEditor.PHPView)
        outlineService.AddViewTypeForBackgroundHandler(
            ProjectEditor.ProjectView
        )  # special case, don't clear outline if in project
        outlineService.AddViewTypeForBackgroundHandler(
            MessageService.MessageView
        )  # special case, don't clear outline if in message window
        if not ACTIVEGRID_BASE_IDE:
            outlineService.AddViewTypeForBackgroundHandler(
                DataModelEditor.DataModelView)
            outlineService.AddViewTypeForBackgroundHandler(
                ProcessModelEditor.ProcessModelView)
            outlineService.AddViewTypeForBackgroundHandler(
                PropertyService.PropertyView
            )  # special case, don't clear outline if in property window
        outlineService.StartBackgroundTimer()

        ##        projectService.AddLogicalViewFolderDefault(".agp", _("Projects"))
        ##        projectService.AddLogicalViewFolderDefault(".wsdlag", _("Services"))
        ##        projectService.AddLogicalViewFolderDefault(".wsdl", _("Services"))
        ##        projectService.AddLogicalViewFolderDefault(".xsd", _("Data Models"))
        ##        projectService.AddLogicalViewFolderDefault(".bpel", _("Page Flows"))
        ##        projectService.AddLogicalViewFolderDefault(".xform", _("Pages"))
        ##        projectService.AddLogicalViewFolderDefault(".xacml", _("Security"))
        ##        projectService.AddLogicalViewFolderDefault(".lyt", _("Presentation/Layouts"))
        ##        projectService.AddLogicalViewFolderDefault(".skn", _("Presentation/Skins"))
        ##        projectService.AddLogicalViewFolderDefault(".css", _("Presentation/Stylesheets"))
        ##        projectService.AddLogicalViewFolderDefault(".js", _("Presentation/Javascript"))
        ##        projectService.AddLogicalViewFolderDefault(".html", _("Presentation/Static"))
        ##        projectService.AddLogicalViewFolderDefault(".htm", _("Presentation/Static"))
        ##        projectService.AddLogicalViewFolderDefault(".gif", _("Presentation/Images"))
        ##        projectService.AddLogicalViewFolderDefault(".jpeg", _("Presentation/Images"))
        ##        projectService.AddLogicalViewFolderDefault(".jpg", _("Presentation/Images"))
        ##        projectService.AddLogicalViewFolderDefault(".png", _("Presentation/Images"))
        ##        projectService.AddLogicalViewFolderDefault(".ico", _("Presentation/Images"))
        ##        projectService.AddLogicalViewFolderDefault(".bmp", _("Presentation/Images"))
        ##        projectService.AddLogicalViewFolderDefault(".py", _("Code"))
        ##        projectService.AddLogicalViewFolderDefault(".php", _("Code"))
        ##        projectService.AddLogicalViewFolderDefault(".pl", _("Code"))
        ##        projectService.AddLogicalViewFolderDefault(".sql", _("Code"))
        ##        projectService.AddLogicalViewFolderDefault(".xml", _("Code"))
        ##        projectService.AddLogicalViewFolderDefault(".dpl", _("Code"))
        ##
        ##        projectService.AddLogicalViewFolderCollapsedDefault(_("Page Flows"), False)
        ##        projectService.AddLogicalViewFolderCollapsedDefault(_("Pages"), False)

        iconPath = os.path.join(sysutilslib.mainModuleDir, "noval", "tool",
                                "bmp_source", "noval.ico")
        self.SetDefaultIcon(wx.Icon(iconPath, wx.BITMAP_TYPE_ICO))
        if not ACTIVEGRID_BASE_IDE:
            embeddedWindows = wx.lib.pydocview.EMBEDDED_WINDOW_TOPLEFT | wx.lib.pydocview.EMBEDDED_WINDOW_BOTTOMLEFT | wx.lib.pydocview.EMBEDDED_WINDOW_BOTTOM | wx.lib.pydocview.EMBEDDED_WINDOW_RIGHT
        else:
            embeddedWindows = wx.lib.pydocview.EMBEDDED_WINDOW_TOPLEFT | wx.lib.pydocview.EMBEDDED_WINDOW_BOTTOMLEFT | wx.lib.pydocview.EMBEDDED_WINDOW_BOTTOM
        if self.GetUseTabbedMDI():
            self.frame = TabbedFrame.IDEDocTabbedParentFrame(
                docManager,
                None,
                -1,
                wx.GetApp().GetAppName(),
                embeddedWindows=embeddedWindows,
                minSize=150)
        else:
            self.frame = TabbedFrame.IDEMDIParentFrame(
                docManager,
                None,
                -1,
                wx.GetApp().GetAppName(),
                embeddedWindows=embeddedWindows,
                minSize=150)
        self.frame.Show(True)
        self.toolbar = self.frame.GetToolBar()
        self.toolbar_combox = self.toolbar.FindControl(
            DebuggerService.DebuggerService.COMBO_INTERPRETERS_ID)

        wx.lib.pydocview.DocApp.CloseSplash(self)
        self.OpenCommandLineArgs()

        if not projectService.LoadSavedProjects(
        ) and not docManager.GetDocuments() and self.IsSDI(
        ):  # Have to open something if it's SDI and there are no projects...
            projectTemplate.CreateDocument(
                '', wx.lib.docview.DOC_NEW).OnNewDocument()

        interpretermanager.InterpreterManager().LoadDefaultInterpreter()
        self.AddInterpreters()
        projectService.SetCurrentProject()
        intellisence.IntellisenceManager().generate_default_intellisence_data()

        self.ShowTipfOfDay()
        wx.CallAfter(self.CheckUpdate, extensionService)
        wx.UpdateUIEvent.SetUpdateInterval(
            1000
        )  # Overhead of updating menus was too much.  Change to update every n milliseconds.
        return True
示例#5
0
文件: IDE.py 项目: ver007/NovalIDE
 def OnExit(self):
     intellisence.IntellisenceManager().Stop()
     UserDataDb.get_db().RecordEnd()
     wx.lib.pydocview.DocApp.OnExit(self)