Exemplo n.º 1
0
 def on_addInstalledApiFileButton_clicked(self):
     """
     Private slot to add an API file from the list of installed API files
     for the selected lexer language.
     """
     installedAPIFiles = self.__currentAPI.installedAPIFiles()
     if len(installedAPIFiles) > 0:
         installedAPIFilesPath = QFileInfo(installedAPIFiles[0]).path()
         installedAPIFilesShort = QStringList()
         for installedAPIFile in installedAPIFiles:
             installedAPIFilesShort.append(QFileInfo(installedAPIFile).fileName())
         file, ok = KQInputDialog.getItem(
             self,
             self.trUtf8("Add from installed APIs"),
             self.trUtf8("Select from the list of installed API files"),
             installedAPIFilesShort,
             0,
             False,
         )
         if ok:
             self.apiList.addItem(
                 Utilities.toNativeSeparators(QFileInfo(QDir(installedAPIFilesPath), file).absoluteFilePath())
             )
     else:
         KQMessageBox.warning(
             self,
             self.trUtf8("Add from installed APIs"),
             self.trUtf8("""There are no APIs installed yet.""" """ Selection is not available."""),
         )
         self.addInstalledApiFileButton.setEnabled(False)
 def on_namedReferenceButton_clicked(self):
     """
     Private slot to handle the named reference toolbutton.
     """
     # determine cursor position as length into text
     length = self.regexpTextEdit.textCursor().position()
     
     # only present group names that occur before the current cursor position
     regex = unicode(self.regexpTextEdit.toPlainText().left(length))
     names = self.namedGroups(regex)
     if not names:
         KQMessageBox.information(None,
             self.trUtf8("Named reference"),
             self.trUtf8("""No named groups have been defined yet."""))
         return
         
     qs = QStringList()
     for name in names:
         qs.append(name)
     groupName, ok = KQInputDialog.getItem(\
         None,
         self.trUtf8("Named reference"),
         self.trUtf8("Select group name:"),
         qs,
         0, True)
     if ok and not groupName.isEmpty():
         self.__insertString("(?P=%s)" % groupName)
Exemplo n.º 3
0
 def __askForkTo(self):
     """
     Private method to ask the user which branch of a fork to follow.
     """
     selections = [self.trUtf8("Parent Process"), self.trUtf8("Child process")]
     res, ok = KQInputDialog.getItem(
         None, self.trUtf8("Client forking"), self.trUtf8("Select the fork branch to follow."), selections, 0, False
     )
     if not ok or res == selections[0]:
         self.__sendCommand(ResponseForkTo + "parent\n")
     else:
         self.__sendCommand(ResponseForkTo + "child\n")
 def on_allEolFillButton_clicked(self):
     """
     Private method used to set the eolfill for all styles of a selected lexer.
     """
     on = self.trUtf8("Enabled")
     off = self.trUtf8("Disabled")
     selection, ok = KQInputDialog.getItem(\
         self,
         self.trUtf8("Fill to end of line"),
         self.trUtf8("Select fill to end of line for all styles"),
         QStringList() << on << off, 
         0, False)
     if ok:
         enabled = selection == on
         self.eolfillCheckBox.setChecked(enabled)
         for style in self.lexer.ind2style.values():
             self.lexer.setEolFill(enabled, style)
Exemplo n.º 5
0
 def on_addPluginApiFileButton_clicked(self):
     """
     Private slot to add an API file from the list of API files installed
     by plugins for the selected lexer language.
     """
     pluginAPIFiles = self.pluginManager.getPluginApiFiles(self.currentApiLanguage)
     pluginAPIFilesDict = {}
     for apiFile in pluginAPIFiles:
         pluginAPIFilesDict[unicode(QFileInfo(apiFile).fileName())] = apiFile
     file, ok = KQInputDialog.getItem(
         self,
         self.trUtf8("Add from Plugin APIs"),
         self.trUtf8("Select from the list of API files installed by plugins"),
         sorted(pluginAPIFilesDict.keys()),
         0,
         False,
     )
     if ok:
         self.apiList.addItem(Utilities.toNativeSeparators(pluginAPIFilesDict[unicode(file)]))
Exemplo n.º 6
0
 def _vcsImport(self):
     """
     Protected slot used to import the local project into the repository.
     
     <b>NOTE</b>: 
         This does not necessarily make the local project a vcs controlled
         project. You may have to checkout the project from the repository in 
         order to accomplish that.
     """
     def revertChanges():
         """
         Local function do revert the changes made to the project object.
         """
         self.project.pdata["VCS"] = pdata_vcs[:]
         self.project.pdata["VCSOPTIONS"] = copy.deepcopy(pdata_vcsoptions)
         self.project.pdata["VCSOTHERDATA"] = copy.deepcopy(pdata_vcsother)
         self.project.vcs = vcs
         self.project.vcsProjectHelper = vcsHelper
         self.project.vcsBasicHelper = vcs is None
         self.initMenu(self.project.vcsMenu)
         self.project.setDirty(True)
         self.project.saveProject()
     
     pdata_vcs = self.project.pdata["VCS"][:]
     pdata_vcsoptions = copy.deepcopy(self.project.pdata["VCSOPTIONS"])
     pdata_vcsother = copy.deepcopy(self.project.pdata["VCSOTHERDATA"])
     vcs = self.project.vcs
     vcsHelper = self.project.vcsProjectHelper
     vcsSystemsDict = e4App().getObject("PluginManager")\
         .getPluginDisplayStrings("version_control")
     if not vcsSystemsDict:
         # no version control system found
         return
     
     vcsSystemsDisplay = QStringList()
     keys = vcsSystemsDict.keys()
     keys.sort()
     for key in keys:
         vcsSystemsDisplay.append(vcsSystemsDict[key])
     vcsSelected, ok = KQInputDialog.getItem(\
         None,
         self.trUtf8("Import Project"),
         self.trUtf8("Select version control system for the project"),
         vcsSystemsDisplay,
         0, False)
     if not ok:
         return
     vcsSystem = None
     for vcsSystem, vcsSystemDisplay in vcsSystemsDict.items():
         if vcsSystemDisplay == vcsSelected:
             break
     
     if vcsSystem:
         self.project.pdata["VCS"] = [vcsSystem]
         self.project.vcs = self.project.initVCS(vcsSystem)
         if self.project.vcs is not None:
             vcsdlg = self.project.vcs.vcsOptionsDialog(self.project, self.project.name, 1)
             if vcsdlg.exec_() == QDialog.Accepted:
                 vcsDataDict = vcsdlg.getData()
                 # edit VCS command options
                 vcores = KQMessageBox.question(None,
                     self.trUtf8("Import Project"),
                     self.trUtf8("""Would you like to edit the VCS command options?"""),
                     QMessageBox.StandardButtons(\
                         QMessageBox.No | \
                         QMessageBox.Yes),
                     QMessageBox.No)
                 if vcores == QMessageBox.Yes:
                     codlg = vcsCommandOptionsDialog(self.project.vcs)
                     if codlg.exec_() == QDialog.Accepted:
                         self.project.vcs.vcsSetOptions(codlg.getOptions())
                 self.project.setDirty(True)
                 self.project.vcs.vcsSetDataFromDict(vcsDataDict)
                 self.project.saveProject()
                 isVcsControlled = \
                     self.project.vcs.vcsImport(vcsDataDict, self.project.ppath)[0]
                 if isVcsControlled:
                     # reopen the project
                     self.project.openProject(self.project.pfile)
                 else:
                     # revert the changes to the local project 
                     # because the project dir is not a VCS directory
                     revertChanges()
             else:
                 # revert the changes because user cancelled
                 revertChanges()
Exemplo n.º 7
0
 def _vcsCheckout(self, export = False):
     """
     Protected slot used to create a local project from the repository.
     
     @param export flag indicating whether an export or a checkout
             should be performed
     """
     if not self.project.checkDirty():
         return
     
     vcsSystemsDict = e4App().getObject("PluginManager")\
         .getPluginDisplayStrings("version_control")
     if not vcsSystemsDict:
         # no version control system found
         return
     
     vcsSystemsDisplay = QStringList()
     keys = vcsSystemsDict.keys()
     keys.sort()
     for key in keys:
         vcsSystemsDisplay.append(vcsSystemsDict[key])
     vcsSelected, ok = KQInputDialog.getItem(\
         None,
         self.trUtf8("New Project"),
         self.trUtf8("Select version control system for the project"),
         vcsSystemsDisplay,
         0, False)
     if not ok:
         return
     for vcsSystem, vcsSystemDisplay in vcsSystemsDict.items():
         if vcsSystemDisplay == vcsSelected:
             break
     
     if not self.project.closeProject():
         return
     
     self.project.pdata["VCS"] = [vcsSystem]
     self.project.vcs = self.project.initVCS(vcsSystem)
     if self.project.vcs is not None:
         vcsdlg = self.project.vcs.vcsNewProjectOptionsDialog()
         if vcsdlg.exec_() == QDialog.Accepted:
             projectdir, vcsDataDict = vcsdlg.getData()
             self.project.pdata["VCS"] = [vcsSystem]
             self.project.vcs = self.project.initVCS(vcsSystem)
             # edit VCS command options
             vcores = KQMessageBox.question(None,
                 self.trUtf8("New Project"),
                 self.trUtf8("""Would you like to edit the VCS command options?"""),
                 QMessageBox.StandardButtons(\
                     QMessageBox.No | \
                     QMessageBox.Yes),
                 QMessageBox.No)
             if vcores == QMessageBox.Yes:
                 codlg = vcsCommandOptionsDialog(self.project.vcs)
                 if codlg.exec_() == QDialog.Accepted:
                     self.project.vcs.vcsSetOptions(codlg.getOptions())
             
             # create the project directory if it doesn't exist already
             if not os.path.isdir(projectdir):
                 try:
                     os.makedirs(projectdir)
                 except EnvironmentError:
                     KQMessageBox.critical(None,
                         self.trUtf8("Create project directory"),
                         self.trUtf8("<p>The project directory <b>%1</b> could not"
                             " be created.</p>").arg(projectdir))
                     self.project.pdata["VCS"] = ['None']
                     self.project.vcs = self.project.initVCS()
                     return
             
             # create the project from the VCS
             self.project.vcs.vcsSetDataFromDict(vcsDataDict)
             if export:
                 ok = self.project.vcs.vcsExport(vcsDataDict, projectdir)
             else:
                 ok = self.project.vcs.vcsCheckout(vcsDataDict, projectdir, False)
             if ok:
                 projectdir = os.path.normpath(projectdir)
                 filters = QStringList() << "*.e4p" << "*.e4pz" << "*.e3p" << "*.e3pz"
                 d = QDir(projectdir)
                 plist = d.entryInfoList(filters)
                 if len(plist):
                     if len(plist) == 1:
                         self.project.openProject(plist[0].absoluteFilePath())
                         self.project.emit(SIGNAL('newProject'))
                     else:
                         pfilenamelist = d.entryList(filters)
                         pfilename, ok = KQInputDialog.getItem(
                             None,
                             self.trUtf8("New project from repository"),
                             self.trUtf8("Select a project file to open."),
                             pfilenamelist, 0, False)
                         if ok:
                             self.project.openProject(\
                                 QFileInfo(d, pfilename).absoluteFilePath())
                             self.project.emit(SIGNAL('newProject'))
                     if export:
                         self.project.pdata["VCS"] = ['None']
                         self.project.vcs = self.project.initVCS()
                         self.project.setDirty(True)
                         self.project.saveProject()
                 else:
                     res = KQMessageBox.question(None,
                         self.trUtf8("New project from repository"),
                         self.trUtf8("The project retrieved from the repository"
                             " does not contain an eric project file"
                             " (*.e4p *.e4pz *.e3p *.e3pz)."
                             " Create it?"),
                         QMessageBox.StandardButtons(\
                             QMessageBox.No | \
                             QMessageBox.Yes),
                         QMessageBox.Yes)
                     if res == QMessageBox.Yes:
                         self.project.ppath = projectdir
                         self.project.opened = True
                         
                         from Project.PropertiesDialog import PropertiesDialog
                         dlg = PropertiesDialog(self.project, False)
                         if dlg.exec_() == QDialog.Accepted:
                             dlg.storeData()
                             self.project.initFileTypes()
                             self.project.setDirty(True)
                             try:
                                 ms = os.path.join(self.project.ppath, 
                                                   self.project.pdata["MAINSCRIPT"][0])
                                 if os.path.exists(ms):
                                     self.project.appendFile(ms)
                             except IndexError:
                                 ms = ""
                             self.project.newProjectAddFiles(ms)
                             self.project.saveProject()
                             self.project.openProject(self.project.pfile)
                             if not export:
                                 res = KQMessageBox.question(None,
                                     self.trUtf8("New project from repository"),
                                     self.trUtf8("Shall the project file be added to"
                                         " the repository?"),
                                     QMessageBox.StandardButtons(\
                                         QMessageBox.No | \
                                         QMessageBox.Yes),
                                     QMessageBox.Yes)
                                 if res == QMessageBox.Yes:
                                     self.project.vcs.vcsAdd(self.project.pfile)
             else:
                 KQMessageBox.critical(None,
                     self.trUtf8("New project from repository"),
                     self.trUtf8("""The project could not be retrieved from"""
                         """ the repository."""))
                 self.project.pdata["VCS"] = ['None']
                 self.project.vcs = self.project.initVCS()
         else:
             self.project.pdata["VCS"] = ['None']
             self.project.vcs = self.project.initVCS()