def __saArguments(self, argsStr): """ Private method used to handle the "Arguments" command. @param argsStr space delimited list of command args(string) """ e4App().getObject("DebugUI").setArgvHistory(argsStr)
def deactivate(self): """ Public method to deactivate this plugin. """ self.disconnect(e4App().getObject("Project"), SIGNAL("showMenu"), self.__projectShowMenu) self.disconnect(e4App().getObject("ProjectBrowser").getProjectBrowser("sources"), SIGNAL("showMenu"), self.__projectBrowserShowMenu) self.disconnect(e4App().getObject("ViewManager"), SIGNAL("editorOpenedEd"), self.__editorOpened) self.disconnect(e4App().getObject("ViewManager"), SIGNAL("editorClosedEd"), self.__editorClosed) menu = e4App().getObject("Project").getMenu("Checks") if menu: menu.removeAction(self.__projectAct) if self.__projectBrowserMenu: if self.__projectBrowserAct: self.__projectBrowserMenu.removeAction(self.__projectBrowserAct) for editor in self.__editors: self.disconnect(editor, SIGNAL("showMenu"), self.__editorShowMenu) menu = editor.getMenu("Checks") if menu is not None: menu.removeAction(self.__editorAct) self.__initialize()
def __saOpenFile(self, fname): """ Private method used to handle the "Open File" command. @param fname filename to be opened (string) """ e4App().getObject("ViewManager").openSourceFile(fname)
def __saOpenProject(self, pfname): """ Private method used to handle the "Open Project" command. @param pfname filename of the project to be opened (string) """ e4App().getObject("Project").openProject(pfname)
def activate(self): """ Public method to activate this plugin. @return tuple of None and activation status (boolean) """ menu = e4App().getObject("Project").getMenu("Apidoc") if menu: self.__projectAct = E4Action( self.trUtf8("Generate API file (eric4_api)"), self.trUtf8("Generate &API file (eric4_api)"), 0, 0, self, "doc_eric4_api", ) self.__projectAct.setStatusTip(self.trUtf8("Generate an API file using eric4_api")) self.__projectAct.setWhatsThis( self.trUtf8("""<b>Generate API file</b>""" """<p>Generate an API file using eric4_api.</p>""") ) self.connect(self.__projectAct, SIGNAL("triggered()"), self.__doEricapi) e4App().getObject("Project").addE4Actions([self.__projectAct]) menu.addAction(self.__projectAct) self.connect(e4App().getObject("Project"), SIGNAL("showMenu"), self.__projectShowMenu) return None, True
def activate(self): """ Public method to activate this plugin. @return tuple of None and activation status (boolean) """ menu = e4App().getObject("Project").getMenu("Apidoc") if menu: self.__projectAct = \ E4Action(self.trUtf8('Generate documentation (eric4_doc)'), self.trUtf8('Generate &documentation (eric4_doc)'), 0, 0, self, 'doc_eric4_doc') self.__projectAct.setStatusTip(\ self.trUtf8('Generate API documentation using eric4_doc')) self.__projectAct.setWhatsThis(self.trUtf8( """<b>Generate documentation</b>""" """<p>Generate API documentation using eric4_doc.</p>""" )) self.connect(self.__projectAct, SIGNAL('triggered()'), self.__doEricdoc) e4App().getObject("Project").addE4Actions([self.__projectAct]) menu.addAction(self.__projectAct) self.connect(e4App().getObject("Project"), SIGNAL("showMenu"), self.__projectShowMenu) return None, True
def __configure(self): """ Private method to open the configuration dialog. """ if self.__embeddedBrowser == 1: e4App().getObject("UserInterface").showPreferences("debuggerGeneralPage") elif self.__embeddedBrowser == 2: e4App().getObject("UserInterface").showPreferences("projectBrowserPage")
def __init__(self, project): """ Constructor @param project Reference to the project object to store the information into. """ XMLHandlerBase.__init__(self) self.startDocumentSpecific = self.startDocumentSession self.elements.update({ 'Session' : (self.startSession, self.defaultEndElement), 'MultiProject' : (self.defaultStartElement, self.endMultiProject), 'Project' : (self.defaultStartElement, self.endProject), 'Filename' : (self.startFilename, self.endFilename), 'ActiveWindow' : (self.startFilename, self.endFilename), 'Breakpoint' : (self.startBreakpoint, self.endBreakpoint), 'BpFilename' : (self.defaultStartElement, self.endBFilename), 'Linenumber' : (self.startLinenumber, self.defaultEndElement), 'Condition' : (self.defaultStartElement, self.endCondition), 'Enabled' : (self.startEnabled, self.defaultEndElement), 'Temporary' : (self.startTemporary, self.defaultEndElement), 'Count' : (self.startCount, self.defaultEndElement), 'Watchexpression' : (self.startWatchexpression, self.endWatchexpression), 'Special' : (self.defaultStartElement, self.endSpecial), 'CommandLine' : (self.defaultStartElement, self.endCommandLine), 'WorkingDirectory' : (self.defaultStartElement, self.endWorkingDirectory), 'Environment' : (self.defaultStartElement, self.endEnvironment), 'ReportExceptions' : (self.startReportExceptions, self.defaultEndElement), 'Exceptions' : (self.startExceptions, self.endExceptions), 'Exception' : (self.defaultStartElement, self.endException), 'IgnoredExceptions' : (self.startIgnoredExceptions, self.endIgnoredExceptions), 'IgnoredException' : (self.defaultStartElement, self.endIgnoredException), 'AutoClearShell' : (self.startAutoClearShell, self.defaultEndElement), 'TracePython' : (self.startTracePython, self.defaultEndElement), 'AutoContinue' : (self.startAutoContinue, self.defaultEndElement), 'Bookmark' : (self.startBookmark, self.endBookmark), 'BmFilename' : (self.defaultStartElement, self.endBFilename), #################################################################### ## backward compatibility #################################################################### 'Watchpoint' : (self.startWatchexpression, self.endWatchexpression), # 4.0 'CovexcPattern' : (self.defaultStartElement, self.defaultEndElement), # 4.3 }) self.project = project self.isGlobal = project is None self.project = e4App().getObject("Project") self.multiProject = e4App().getObject("MultiProject") self.vm = e4App().getObject("ViewManager") self.dbg = e4App().getObject("DebugUI") self.dbs = e4App().getObject("DebugServer")
def deactivate(self): """ Public method to deactivate this plugin. """ self.disconnect(e4App().getObject("Project"), SIGNAL("showMenu"), self.__projectShowMenu) menu = e4App().getObject("Project").getMenu("Apidoc") if menu: menu.removeAction(self.__projectAct) e4App().getObject("Project").removeE4Actions([self.__projectAct]) self.__initialize()
def __init__(self, file, projectName): """ Constructor @param file open file (like) object for writing @param projectName name of the project (string) """ XMLWriterBase.__init__(self, file) self.pudata = e4App().getObject("Project").pudata self.pdata = e4App().getObject("Project").pdata self.name = projectName
def on_resultList_itemActivated(self, itm, col): """ Private slot to handle the activation of an item. @param itm reference to the activated item (QTreeWidgetItem) @param col column the item was activated in (integer) """ if self.noResults: return fn = Utilities.normabspath(unicode(itm.text(0))) lineno = int(str(itm.text(1))) e4App().getObject("ViewManager").openSourceFile(fn, lineno)
def __init__(self, file, projectName): """ Constructor @param file open file (like) object for writing @param projectName name of the project (string) or None for the global session """ XMLWriterBase.__init__(self, file) self.name = projectName self.project = e4App().getObject("Project") self.multiProject = e4App().getObject("MultiProject") self.vm = e4App().getObject("ViewManager") self.dbg = e4App().getObject("DebugUI") self.dbs = e4App().getObject("DebugServer")
def __init__(self, parent = None, fromEric = True): """ Constructor @param parent parent widget (QWidget) @param fromEric flag indicating a call from within eric4 """ QWidget.__init__(self,parent) self.setupUi(self) # initialize icons of the tool buttons self.charButton.setIcon(UI.PixmapCache.getIcon("characters.png")) self.anycharButton.setIcon(UI.PixmapCache.getIcon("anychar.png")) self.repeatButton.setIcon(UI.PixmapCache.getIcon("repeat.png")) self.nonGroupButton.setIcon(UI.PixmapCache.getIcon("nongroup.png")) self.groupButton.setIcon(UI.PixmapCache.getIcon("group.png")) self.altnButton.setIcon(UI.PixmapCache.getIcon("altn.png")) self.beglineButton.setIcon(UI.PixmapCache.getIcon("begline.png")) self.endlineButton.setIcon(UI.PixmapCache.getIcon("endline.png")) self.wordboundButton.setIcon(UI.PixmapCache.getIcon("wordboundary.png")) self.nonwordboundButton.setIcon(UI.PixmapCache.getIcon("nonwordboundary.png")) self.poslookaheadButton.setIcon(UI.PixmapCache.getIcon("poslookahead.png")) self.neglookaheadButton.setIcon(UI.PixmapCache.getIcon("neglookahead.png")) self.undoButton.setIcon(UI.PixmapCache.getIcon("editUndo.png")) self.redoButton.setIcon(UI.PixmapCache.getIcon("editRedo.png")) self.saveButton = \ self.buttonBox.addButton(self.trUtf8("Save"), QDialogButtonBox.ActionRole) self.saveButton.setToolTip(self.trUtf8("Save the regular expression to a file")) self.loadButton = \ self.buttonBox.addButton(self.trUtf8("Load"), QDialogButtonBox.ActionRole) self.loadButton.setToolTip(self.trUtf8("Load a regular expression from a file")) self.validateButton = \ self.buttonBox.addButton(self.trUtf8("Validate"), QDialogButtonBox.ActionRole) self.validateButton.setToolTip(self.trUtf8("Validate the regular expression")) self.executeButton = \ self.buttonBox.addButton(self.trUtf8("Execute"), QDialogButtonBox.ActionRole) self.executeButton.setToolTip(self.trUtf8("Execute the regular expression")) self.nextButton = \ self.buttonBox.addButton(self.trUtf8("Next match"), QDialogButtonBox.ActionRole) self.nextButton.setToolTip(\ self.trUtf8("Show the next match of the regular expression")) self.nextButton.setEnabled(False) if fromEric: self.buttonBox.button(QDialogButtonBox.Close).hide() self.copyButton = None uitype = e4App().getObject("Project").getProjectType() else: self.copyButton = \ self.buttonBox.addButton(self.trUtf8("Copy"), QDialogButtonBox.ActionRole) self.copyButton.setToolTip(\ self.trUtf8("Copy the regular expression to the clipboard")) self.buttonBox.button(QDialogButtonBox.Ok).hide() self.buttonBox.button(QDialogButtonBox.Cancel).hide() self.variableLabel.hide() self.variableLineEdit.hide() self.variableLine.hide() self.regexpLineEdit.setFocus()
def __doEricapi(self): """ Private slot to perform the eric4_api api generation. """ project = e4App().getObject("Project") parms = project.getData("DOCUMENTATIONPARMS", "ERIC4API") dlg = EricapiConfigDialog(project, parms) if dlg.exec_() == QDialog.Accepted: args, parms = dlg.generateParameters() project.setData("DOCUMENTATIONPARMS", "ERIC4API", parms) # now do the call dia = EricapiExecDialog("Ericapi") res = dia.start(args, project.ppath) if res: dia.exec_() outputFileName = parms["outputFile"] # add output files to the project data, if they aren't in already for progLanguage in parms["languages"]: if "%L" in outputFileName: outfile = outputFileName.replace("%L", progLanguage) else: if len(parms["languages"]) == 1: outfile = outputFileName else: root, ext = os.path.splitext(outputFileName) outfile = "%s-%s%s" % (root, progLanguage.lower(), ext) outfile = project.getRelativePath(outfile) if outfile not in project.pdata["OTHERS"]: project.pdata["OTHERS"].append(outfile) project.setDirty(True) project.othersAdded(outfile)
def __init__(self, forProject = False, taskViewer=None): """ Constructor @param forProject flag indicating project related mode (boolean) @param taskViewer reference to the task viewer object """ XMLHandlerBase.__init__(self) self.startDocumentSpecific = self.startDocumentTasks self.elements.update({ 'Tasks' : (self.startTasks, self.defaultEndElement), 'Summary' : (self.defaultStartElement, self.endSummary), 'Description' : (self.defaultStartElement, self.endDescription), 'Created' : (self.defaultStartElement, self.endCreated), 'Dir' : (self.defaultStartElement, self.endDir), 'Name' : (self.defaultStartElement, self.endName), 'Filename' : (self.startFilename, self.endFilename), 'Linenumber' : (self.defaultStartElement, self.endLinenumber), 'Task' : (self.startTask, self.endTask), }) self.forProject = forProject if taskViewer: self.taskViewer = taskViewer else: self.taskViewer = e4App().getObject("TaskViewer")
def __init__(self): """ Constructor """ ConfigurationPageBase.__init__(self) self.setupUi(self) self.setObjectName("EditorAPIsPage") self.prepareApiButton.setText(self.trUtf8("Compile APIs")) self.__apisManager = APIsManager() self.__currentAPI = None self.__inPreparation = False self.apiFileCompleter = E4FileCompleter(self.apiFileEdit) # set initial values self.pluginManager = e4App().getObject("PluginManager") self.apiAutoPrepareCheckBox.setChecked(Preferences.getEditor("AutoPrepareAPIs")) self.apis = {} apiLanguages = [""] + QScintilla.Lexers.getSupportedLanguages().keys() apiLanguages.sort() for lang in apiLanguages: if lang != "Guessed": self.apiLanguageComboBox.addItem(lang) self.currentApiLanguage = QString("") self.on_apiLanguageComboBox_activated(self.currentApiLanguage) for lang in apiLanguages[1:]: self.apis[lang] = QStringList(Preferences.getEditorAPI(lang))
def __init__(self): """ Constructor """ ConfigurationPageBase.__init__(self) self.setupUi(self) self.setObjectName("ViewmanagerPage") # set initial values self.pluginManager = e4App().getObject("PluginManager") self.viewmanagers = self.pluginManager.getPluginDisplayStrings("viewmanager") self.windowComboBox.clear() currentVm = Preferences.getViewManager() keys = self.viewmanagers.keys() keys.sort() for key in keys: self.windowComboBox.addItem(self.trUtf8(self.viewmanagers[key]), QVariant(key)) currentIndex = self.windowComboBox.findText(\ self.trUtf8(self.viewmanagers[currentVm])) self.windowComboBox.setCurrentIndex(currentIndex) self.on_windowComboBox_activated(currentIndex) self.tabViewGroupBox.setTitle(self.trUtf8(self.viewmanagers["tabview"])) self.filenameLengthSpinBox.setValue( Preferences.getUI("TabViewManagerFilenameLength")) self.filenameOnlyCheckBox.setChecked( Preferences.getUI("TabViewManagerFilenameOnly")) self.recentFilesSpinBox.setValue( Preferences.getUI("RecentNumber"))
def __init__(self): """ Constructor """ ConfigurationPageBase.__init__(self) self.setupUi(self) self.setObjectName("ProjectBrowserPage") self.projectBrowserColours = {} self.__currentProjectTypeIndex = 0 # set initial values self.projectTypeCombo.addItem('', QVariant('')) self.__projectBrowserFlags = {'' : 0} try: projectTypes = e4App().getObject("Project").getProjectTypes() for projectType in sorted(projectTypes.keys()): self.projectTypeCombo.addItem(projectTypes[projectType], QVariant(projectType)) self.__projectBrowserFlags[projectType] = \ Preferences.getProjectBrowserFlags(projectType) except KeyError: self.pbGroup.setEnabled(False) self.projectBrowserColours["Highlighted"] = \ self.initColour("Highlighted", self.pbHighlightedButton, Preferences.getProjectBrowserColour) self.followEditorCheckBox.setChecked(\ Preferences.getProject("FollowEditor")) self.hideGeneratedCheckBox.setChecked(\ Preferences.getProject("HideGeneratedForms"))
def factory(vcs): """ Modul factory function to generate the right vcs object. @param vcs name of the VCS system to be used (string) @return the instantiated VCS object """ pluginManager = e4App().getObject("PluginManager") if pluginManager is None: # that should not happen vc = None vc = pluginManager.getPluginObject("version_control", vcs, maybeActive = True) if vc is None: # try alternative vcs interfaces assuming, that there is a common # indicator for the alternatives found = False for indicator, vcsData in pluginManager.getVcsSystemIndicators().items(): for vcsSystem, vcsSystemDisplay in vcsData: if vcsSystem == vcs: found = True break if found: if len(vcsData) > 1: for vcsSystem, vcsSystemDisplay in vcsData: if vcsSystem != vcs: vc = pluginManager.getPluginObject( "version_control", vcsSystem, maybeActive = True) if vc is not None: break break return vc
def __captionChange(self, cap, editor): """ Private method to handle Caption change signals from the editor. Updates the listview text to reflect the new caption information. @param cap Caption for the editor @param editor Editor to update the caption for """ fn = editor.getFileName() if fn: if Preferences.getUI("TabViewManagerFilenameOnly"): txt = os.path.basename(fn) else: txt = e4App().getObject("Project").getRelativePath(fn) maxFileNameChars = Preferences.getUI("TabViewManagerFilenameLength") if len(txt) > maxFileNameChars: txt = "...%s" % txt[-maxFileNameChars:] if editor.isReadOnly(): txt = self.trUtf8("%1 (ro)").arg(txt) index = self.indexOf(editor) if index > -1: self.setTabText(index, txt) self.setTabToolTip(index, fn)
def _addView(self, win, fn = None, noName = ""): """ Protected method to add a view (i.e. window) @param win editor window to be added @param fn filename of this editor @param noName name to be used for an unnamed editor (string or QString) """ if fn is None: if not unicode(noName): self.untitledCount += 1 noName = self.trUtf8("Untitled %1").arg(self.untitledCount) self.currentTabWidget.addTab(win, noName) win.setNoName(noName) else: if self.filenameOnly: txt = os.path.basename(fn) else: txt = e4App().getObject("Project").getRelativePath(fn) if len(txt) > self.maxFileNameChars: txt = "...%s" % txt[-self.maxFileNameChars:] if not QFileInfo(fn).isWritable(): txt = self.trUtf8("%1 (ro)").arg(txt) self.currentTabWidget.addTab(win, txt) index = self.currentTabWidget.indexOf(win) self.currentTabWidget.setTabToolTip(index, fn) self.currentTabWidget.setCurrentWidget(win) win.show() win.setFocus() if fn: self.emit(SIGNAL('changeCaption'), unicode(fn)) self.emit(SIGNAL('editorChanged'), unicode(fn)) else: self.emit(SIGNAL('changeCaption'), "")
def __getPredefinedVars(self): """ Private method to return predefined variables. @return dictionary of predefined variables and their values """ project = e4App().getObject("Project") editor = self.viewmanager.activeWindow() today = datetime.datetime.now().date() sepchar = str(Preferences.getTemplates("SeparatorChar")) if sepchar == '%': sepchar = '%%' keyfmt = sepchar + "%s" + sepchar varValues = {keyfmt % 'date': today.isoformat(), keyfmt % 'year': str(today.year)} if project.name: varValues[keyfmt % 'project_name'] = project.name path_name = editor.getFileName() if path_name: dir_name, file_name = os.path.split(path_name) base_name, ext = os.path.splitext(file_name) if ext: ext = ext[1:] varValues.update({ keyfmt % 'path_name': path_name, keyfmt % 'dir_name': dir_name, keyfmt % 'file_name': file_name, keyfmt % 'base_name': base_name, keyfmt % 'ext': ext }) return varValues
def __clearErrors(self): """ Private method to clear all error markers of open editors. """ vm = e4App().getObject("ViewManager") openFiles = vm.getOpenFilenames() for file in openFiles: editor = vm.getOpenEditor(file) editor.clearSyntaxError()
def __init__(self, ui): """ Constructor @param ui reference to the user interface object (UI.UserInterface) """ self.__ui = ui self.__subversionDefaults = {"StopLogOnCopy": 1, "LogLimit": 100, "CommitMessages": 20} from VcsPlugins.vcsPySvn.ProjectHelper import SvnProjectHelper self.__projectHelperObject = SvnProjectHelper(None, None) try: e4App().registerPluginObject(pluginTypename, self.__projectHelperObject, pluginType) except KeyError: pass # ignore duplicate registration readShortcuts(pluginName=pluginTypename)
def __editorSyntaxCheck(self): """ Private slot to handle the syntax check context menu action of the editors. """ editor = e4App().getObject("ViewManager").activeWindow() if editor is not None: self.__editorSyntaxCheckerDialog = SyntaxCheckerDialog() self.__editorSyntaxCheckerDialog.show() self.__editorSyntaxCheckerDialog.start(editor.getFileName(), unicode(editor.text()))
def writeXML(self): """ Public method to write the XML to the file. """ XMLWriterBase.writeXML(self) self._write('<!DOCTYPE Tasks SYSTEM "Tasks-%s.dtd">' % tasksFileFormatVersion) # add some generation comments if self.forProject: self._write("<!-- eric4 tasks file for project %s -->" % self.name) if Preferences.getProject("XMLTimestamp"): self._write("<!-- Saved: %s -->" % time.strftime('%Y-%m-%d, %H:%M:%S')) else: self._write("<!-- eric4 tasks file -->") self._write("<!-- Saved: %s -->" % time.strftime('%Y-%m-%d, %H:%M:%S')) # add the main tag self._write('<Tasks version="%s">' % tasksFileFormatVersion) # do the tasks if self.forProject: tasks = e4App().getObject("TaskViewer").getProjectTasks() else: tasks = e4App().getObject("TaskViewer").getGlobalTasks() for task in tasks: self._write(' <Task priority="%d" completed="%s" bugfix="%s">' % \ (task.priority, task.completed, task.isBugfixTask)) self._write(' <Summary>%s</Summary>' % \ self.escape("%s" % task.description.strip())) self._write(' <Description>%s</Description>' % \ self.escape(self.encodedNewLines(task.longtext.strip()))) self._write(' <Created>%s</Created>' % \ time.strftime("%Y-%m-%d, %H:%M:%S", time.localtime(task.created))) if task.filename: self._write(' <Resource>') self._write(' <Filename>%s</Filename>' % \ Utilities.fromNativeSeparators(task.filename)) self._write(' <Linenumber>%d</Linenumber>' % task.lineno) self._write(' </Resource>') self._write(' </Task>') self._write('</Tasks>', newline = False)
def shutdown(self): """ Public method to shut down the object. This method does some preparations so the object can be deleted properly. It disconnects from the focusChanged signal in order to avoid trouble later on. """ self.disconnect(e4App(), SIGNAL("focusChanged(QWidget*, QWidget*)"), self.__appFocusChanged)
def expand(self): """ Public method to expand the item. """ self.deleteChildren() self.populated = True pathlist = [str(self.text(0))] par = self.parent() # step 1: get a pathlist up to the requested variable while par is not None: pathlist.insert(0, str(par.text(0))) par = par.parent() # step 2: request the variable from the debugger filter = e4App().getObject("DebugUI").variablesFilter(self.scope) e4App().getObject("DebugServer").remoteClientVariable(\ self.scope, filter, pathlist, self.framenr)
def __projectShowMenu(self, menuName, menu): """ Private slot called, when the the project menu or a submenu is about to be shown. @param menuName name of the menu to be shown (string) @param menu reference to the menu (QMenu) """ if menuName == "Checks" and self.__projectAct is not None: self.__projectAct.setEnabled(\ e4App().getObject("Project").getProjectLanguage() == "Python")
def clearCachedState(self, name): """ Public method to clear the cached VCS state of a file/directory. @param name name of the entry to be cleared (QString or string) """ project = e4App().getObject("Project") key = project.getRelativePath(unicode(name)) try: del self.reportedStates[key] except KeyError: pass