def save_scheme(self):
        """Save current scheme."""
        name = self.line_name.text().strip()
        if not self._is_valid_scheme_name(name):
            QMessageBox.information(
                self, translations.TR_PREFERENCES_EDITOR_SCHEME_DESIGNER,
                translations.TR_SCHEME_INVALID_NAME)
            return
        fileName = ('{0}.color'.format(
            file_manager.create_path(resources.EDITOR_SKINS, name)))
        answer = True
        if file_manager.file_exists(fileName):
            answer = QMessageBox.question(
                self, translations.TR_PREFERENCES_EDITOR_SCHEME_DESIGNER,
                translations.TR_WANT_OVERWRITE_FILE + ": {0}?".format(fileName),
                QMessageBox.Yes, QMessageBox.No)

        if answer in (QMessageBox.Yes, True):
            scheme = self._preview_style()
            self.original_style = copy.copy(scheme)
            json_manager.save_editor_skins(fileName, scheme)
            self._modified = False
            self.saved = True
            qsettings = IDE.ninja_settings()
            qsettings.setValue('preferences/editor/scheme', name)
            QMessageBox.information(
                self, translations.TR_PREFERENCES_EDITOR_SCHEME_DESIGNER,
                translations.TR_SCHEME_SAVED + ": {0}.".format(fileName))
            self.close()
        elif answer == QMessageBox.Yes:
            QMessageBox.information(
                self, translations.TR_PREFERENCES_EDITOR_SCHEME_DESIGNER,
                translations.TR_INVALID_FILENAME)
    def save_stylesheet(self):
        try:
            file_name = "%s.qss" % self.line_name.text()
            if not self._is_valid_scheme_name(file_name):
                QMessageBox.information(self,
                                        translations.TR_PREFERENCES_THEME,
                                        translations.TR_SCHEME_INVALID_NAME)
            file_name = ('{0}.qss'.format(
                file_manager.create_path(resources.NINJA_THEME_DOWNLOAD,
                                         file_name)))
            content = self.edit_qss.toPlainText()
            answer = True
            if file_manager.file_exists(file_name):
                answer = QMessageBox.question(
                    self, translations.TR_PREFERENCES_THEME,
                    translations.TR_WANT_OVERWRITE_FILE +
                    ": {0}?".format(file_name), QMessageBox.Yes,
                    QMessageBox.No)

            if answer in (QMessageBox.Yes, True):
                self.apply_stylesheet()
                file_manager.store_file_content(file_name,
                                                content,
                                                newFile=True)
                self.close()
        except file_manager.NinjaFileExistsException as ex:
            QMessageBox.information(
                self, self.tr("File Already Exists"),
                (self.tr("Invalid File Name: the file '%s' already exists.") %
                 ex.filename))
    def save_properties(self):
        if self.projectData.name.text().strip() == '':
            QMessageBox.critical(self, self.tr("Properties Invalid"),
                self.tr("The Project must have a name."))
            return

        tempName = self._item.name
        self._item.name = self.projectData.name.text()
        self._item.description = self.projectData.description.toPlainText()
        self._item.license = self.projectData.cboLicense.currentText()
        self._item.mainFile = self.projectExecution.path.text()
        self._item.url = self.projectData.url.text()
        self._item.projectType = self.projectData.txtType.text()
        # FIXME
        self._item.pythonPath = self.projectExecution.txtPythonPath.text()
        self._item.PYTHONPATH = self.projectExecution.PYTHONPATH.toPlainText()
        self._item.additional_builtins = filter(
                lambda e: e,  # remove empty names
                self.projectExecution.additional_builtins.text().split(' '))
        self._item.preExecScript = self.projectExecution.txtPreExec.text()
        self._item.postExecScript = self.projectExecution.txtPostExec.text()
        self._item.programParams = self.projectExecution.txtParams.text()
        self._item.venv = self.projectExecution.txtVenvPath.text()
        extensions = self.projectData.txtExtensions.text().split(', ')
        self._item.extensions = tuple(extensions)
        self._item.indentation = self.projectData.spinIndentation.value()
        self._item.useTabs = self.projectData.checkUseTabs.isChecked()
        related = self.projectMetadata.txt_projects.toPlainText()
        related = [path for path in related.split('\n') if path != '']
        self._item.related_projects = related
        #save project properties
        project = {}
        project['name'] = self._item.name
        project['description'] = self._item.description
        project['url'] = self._item.url
        project['license'] = self._item.license
        project['mainFile'] = self._item.mainFile
        project['project-type'] = self._item.projectType
        project['supported-extensions'] = self._item.extensions
        project['indentation'] = self._item.indentation
        project['use-tabs'] = self._item.useTabs
        project['pythonPath'] = self._item.pythonPath  # FIXME
        project['PYTHONPATH'] = self._item.PYTHONPATH
        project['additional_builtins'] = self._item.additional_builtins
        project['preExecScript'] = self._item.preExecScript
        project['postExecScript'] = self._item.postExecScript
        project['venv'] = self._item.venv
        project['programParams'] = self._item.programParams
        project['relatedProjects'] = self._item.related_projects
        if tempName != self._item.name and \
            file_manager.file_exists(self._item.path, tempName + '.nja'):
            file_manager.delete_file(self._item.path, tempName + '.nja')
        json_manager.create_ninja_project(
            self._item.path, self._item.name, project)
        self._item.setText(0, self._item.name)
        self._item.setToolTip(0, self._item.name)
        if self._item.extensions != settings.SUPPORTED_EXTENSIONS:
            self._item._parent._refresh_project(self._item)
        self._item.update_paths()
        self.close()
    def save_properties(self):
        if self.projectData.name.text().strip() == '':
            QMessageBox.critical(self, self.tr("Properties Invalid"),
                                 self.tr("The Project must have a name."))
            return

        tempName = self._item.name
        self._item.name = self.projectData.name.text()
        self._item.description = self.projectData.description.toPlainText()
        self._item.license = self.projectData.cboLicense.currentText()
        self._item.mainFile = self.projectExecution.path.text()
        self._item.url = self.projectData.url.text()
        self._item.projectType = self.projectData.txtType.text()
        # FIXME
        self._item.pythonPath = self.projectExecution.txtPythonPath.text()
        self._item.PYTHONPATH = self.projectExecution.PYTHONPATH.toPlainText()
        self._item.additional_builtins = filter(
            lambda e: e,  # remove empty names
            self.projectExecution.additional_builtins.text().split(' '))
        self._item.preExecScript = self.projectExecution.txtPreExec.text()
        self._item.postExecScript = self.projectExecution.txtPostExec.text()
        self._item.programParams = self.projectExecution.txtParams.text()
        self._item.venv = self.projectExecution.txtVenvPath.text()
        extensions = self.projectData.txtExtensions.text().split(', ')
        self._item.extensions = tuple(extensions)
        self._item.indentation = self.projectData.spinIndentation.value()
        self._item.useTabs = self.projectData.checkUseTabs.isChecked()
        related = self.projectMetadata.txt_projects.toPlainText()
        related = [path for path in related.split('\n') if path != '']
        self._item.related_projects = related
        #save project properties
        project = {}
        project['name'] = self._item.name
        project['description'] = self._item.description
        project['url'] = self._item.url
        project['license'] = self._item.license
        project['mainFile'] = self._item.mainFile
        project['project-type'] = self._item.projectType
        project['supported-extensions'] = self._item.extensions
        project['indentation'] = self._item.indentation
        project['use-tabs'] = self._item.useTabs
        project['pythonPath'] = self._item.pythonPath  # FIXME
        project['PYTHONPATH'] = self._item.PYTHONPATH
        project['additional_builtins'] = self._item.additional_builtins
        project['preExecScript'] = self._item.preExecScript
        project['postExecScript'] = self._item.postExecScript
        project['venv'] = self._item.venv
        project['programParams'] = self._item.programParams
        project['relatedProjects'] = self._item.related_projects
        if tempName != self._item.name and \
            file_manager.file_exists(self._item.path, tempName + '.nja'):
            file_manager.delete_file(self._item.path, tempName + '.nja')
        json_manager.create_ninja_project(self._item.path, self._item.name,
                                          project)
        self._item.setText(0, self._item.name)
        self._item.setToolTip(0, self._item.name)
        if self._item.extensions != settings.SUPPORTED_EXTENSIONS:
            self._item._parent._refresh_project(self._item)
        self._item.update_paths()
        self.close()
Exemple #5
0
    def save_scheme(self):
        name = self.line_name.text().strip()
        if not self._is_valid_scheme_name(name):
            QMessageBox.information(
                self, self.tr("Invalid Scheme Name"),
                self.tr("The scheme name you have chosen is invalid.\nPlease "
                        "pick a different name."))
            return
        fileName = ('{0}.color'.format(
            file_manager.create_path(resources.EDITOR_SKINS, name)))
        answer = True
        if file_manager.file_exists(fileName):
            answer = QMessageBox.question(
                self, self.tr("Scheme already exists"),
                (self.tr("Do you want to override the file: %s?") % fileName),
                QMessageBox.Yes, QMessageBox.No)

        if answer in (QMessageBox.Yes, True):
            scheme = self._preview_style()
            self.original_style = copy.copy(scheme)
            json_manager.save_editor_skins(fileName, scheme)
            self._modified = False
            self.saved = True
            qsettings = IDE.ninja_settings()
            qsettings.setValue('preferences/editor/scheme', name)
            QMessageBox.information(
                self, self.tr("Scheme Saved"),
                (self.tr("The scheme has been saved at: %s.") % fileName))
            self.close()
        elif answer == QMessageBox.Yes:
            QMessageBox.information(self, self.tr("Scheme Not Saved"),
                                    self.tr("The name probably is invalid."))
    def save_stylesheet(self):
        try:
            file_name = "%s.qss" % self.line_name.text()
            if not self._is_valid_scheme_name(file_name):
                QMessageBox.information(
                    self, translations.TR_PREFERENCES_THEME,
                    translations.TR_SCHEME_INVALID_NAME)
            file_name = ('{0}.qss'.format(
                file_manager.create_path(
                    resources.NINJA_THEME_DOWNLOAD, file_name)))
            content = self.edit_qss.toPlainText()
            answer = True
            if file_manager.file_exists(file_name):
                answer = QMessageBox.question(
                    self, translations.TR_PREFERENCES_THEME,
                    translations.TR_WANT_OVERWRITE_FILE + ": {0}?".format(
                        file_name),
                    QMessageBox.Yes, QMessageBox.No)

            if answer in (QMessageBox.Yes, True):
                self.apply_stylesheet()
                file_manager.store_file_content(
                    file_name, content, newFile=True)
                self.close()
        except file_manager.NinjaFileExistsException as ex:
            QMessageBox.information(
                self, self.tr("File Already Exists"),
                (self.tr("Invalid File Name: the file '%s' already exists.") %
                    ex.filename))
    def save_scheme(self):
        """Save current scheme."""
        name = self.line_name.text().strip()
        if not self._is_valid_scheme_name(name):
            QMessageBox.information(
                self, translations.TR_PREFERENCES_EDITOR_SCHEME_DESIGNER,
                translations.TR_SCHEME_INVALID_NAME)
            return
        fileName = ('{0}.color'.format(
            file_manager.create_path(resources.EDITOR_SKINS, name)))
        answer = True
        if file_manager.file_exists(fileName):
            answer = QMessageBox.question(
                self, translations.TR_PREFERENCES_EDITOR_SCHEME_DESIGNER,
                translations.TR_WANT_OVERWRITE_FILE +
                ": {0}?".format(fileName), QMessageBox.Yes, QMessageBox.No)

        if answer in (QMessageBox.Yes, True):
            scheme = self._preview_style()
            self.original_style = copy.copy(scheme)
            json_manager.save_editor_skins(fileName, scheme)
            self._modified = False
            self.saved = True
            qsettings = IDE.ninja_settings()
            qsettings.setValue('preferences/editor/scheme', name)
            QMessageBox.information(
                self, translations.TR_PREFERENCES_EDITOR_SCHEME_DESIGNER,
                translations.TR_SCHEME_SAVED + ": {0}.".format(fileName))
            self.close()
        elif answer == QMessageBox.Yes:
            QMessageBox.information(
                self, translations.TR_PREFERENCES_EDITOR_SCHEME_DESIGNER,
                translations.TR_INVALID_FILENAME)
    def save_scheme(self):
        name = self.line_name.text().strip()
        if not self._is_valid_scheme_name(name):
            QMessageBox.information(self, self.tr("Invalid Scheme Name"),
                self.tr("The scheme name you have chosen is invalid.\nPlease "
                    "pick a different name."))
            return
        fileName = ('{0}.color'.format(
            file_manager.create_path(resources.EDITOR_SKINS, name)))
        answer = True
        if file_manager.file_exists(fileName):
            answer = QMessageBox.question(self,
                self.tr("Scheme already exists"),
                (self.tr("Do you want to override the file: %s?") % fileName),
                QMessageBox.Yes, QMessageBox.No)

        if answer in (QMessageBox.Yes, True):
            scheme = self._preview_style()
            self.original_style = copy.copy(scheme)
            json_manager.save_editor_skins(fileName, scheme)
            self._modified = False
            self.saved = True
            qsettings = IDE.ninja_settings()
            qsettings.setValue('preferences/editor/scheme', name)
            QMessageBox.information(self, self.tr("Scheme Saved"),
                    (self.tr("The scheme has been saved at: %s.") % fileName))
            self.close()
        elif answer == QMessageBox.Yes:
            QMessageBox.information(self, self.tr("Scheme Not Saved"),
                self.tr("The name probably is invalid."))
Exemple #9
0
 def load_session_files_projects(self, files, projects, current_file, recent_files=None):
     """Load the files and projects from previous session."""
     main_container = IDE.get_service("main_container")
     projects_explorer = IDE.get_service("projects_explorer")
     if main_container and files:
         for fileData in files:
             if file_manager.file_exists(fileData[0]):
                 mtime = os.stat(fileData[0]).st_mtime
                 ignore_checkers = mtime == fileData[2]
                 main_container.open_file(fileData[0], fileData[1], ignore_checkers=ignore_checkers)
         if current_file:
             main_container.open_file(current_file)
     if projects_explorer and projects:
         projects_explorer.load_session_projects(projects)
 def _load_session_data(self, key):
     """Activate the selected session, closing the current files/projects"""
     main_container = self._ide.get_service("main_container")
     projects_explorer = self._ide.get_service("projects_explorer")
     if projects_explorer and main_container:
         projects_explorer.close_opened_projects()
         for fileData in settings.SESSIONS[key][0]:
             path, line, stat_value = fileData
             if file_manager.file_exists(path):
                 mtime = os.stat(path).st_mtime
                 ignore_checkers = mtime == stat_value
                 main_container.open_file(path, line, ignore_checkers=ignore_checkers)
         if projects_explorer:
             projects_explorer.load_session_projects(settings.SESSIONS[key][1])
Exemple #11
0
 def load_session_files_projects(self, files, projects,
                                 current_file, recent_files=None):
     """Load the files and projects from previous session."""
     main_container = IDE.get_service('main_container')
     projects_explorer = IDE.get_service('projects_explorer')
     if main_container and files:
         for fileData in files:
             if file_manager.file_exists(fileData[0]):
                 mtime = os.stat(fileData[0]).st_mtime
                 ignore_checkers = (mtime == fileData[2])
                 line, col = fileData[1][0], fileData[1][1]
                 main_container.open_file(fileData[0], line, col,
                                          ignore_checkers=ignore_checkers)
         #if current_file:
             #main_container.open_file(current_file)
     if projects_explorer and projects:
         projects_explorer.load_session_projects(projects)
Exemple #12
0
 def _load_session_data(self, key):
     """Activate the selected session, closing the current files/projects"""
     main_container = self._ide.get_service('main_container')
     projects_explorer = self._ide.get_service('projects_explorer')
     if projects_explorer and main_container:
         projects_explorer.close_opened_projects()
         for fileData in settings.SESSIONS[key][0]:
             path, line, stat_value = fileData
             if file_manager.file_exists(path):
                 mtime = os.stat(path).st_mtime
                 ignore_checkers = (mtime == stat_value)
                 main_container.open_file(path,
                                          line,
                                          ignore_checkers=ignore_checkers)
         if projects_explorer:
             projects_explorer.load_session_projects(
                 settings.SESSIONS[key][1])
Exemple #13
0
 def load_session_files_projects(self, files, projects,
         current_file, recent_files=None):
     """Load the files and projects from previous session."""
     main_container = IDE.get_service('main_container')
     projects_explorer = IDE.get_service('projects_explorer')
     if main_container and files:
         #self.connect(explorer, SIGNAL("projectOpened(QString)"),
             #self._set_editors_project_data)
         for fileData in files:
             if file_manager.file_exists(fileData[0]):
                 mtime = os.stat(fileData[0]).st_mtime
                 ignore_checkers = (mtime == fileData[2])
                 main_container.open_file(fileData[0], fileData[1],
                     ignore_checkers=ignore_checkers)
         if current_file:
             main_container.open_file(current_file)
     if projects_explorer and projects:
         projects_explorer.load_session_projects(projects)
    def load_session(self, session_name):
        """Activate the selected session, closing the current files/projects"""

        main_container = self._ide.get_service("main_container")
        projects_explorer = self._ide.get_service("projects_explorer")
        if projects_explorer and main_container:
            projects_explorer.close_opened_projects()

            for file_data in self.__sessions[session_name][0]:
                path, (line, col), stat_value = file_data
                if file_manager.file_exists(path):
                    mtime = os.stat(path).st_mtime
                    ignore_checkers = (mtime == stat_value)
                    main_container.open_file(path, line, col,
                                             ignore_checkers=ignore_checkers)
            if projects_explorer:
                projects_explorer.load_session_projects(
                    self.__sessions[session_name][1])
Exemple #15
0
    def load_session(self, session_name):
        """Activate the selected session, closing the current files/projects"""

        main_container = self._ide.get_service("main_container")
        projects_explorer = self._ide.get_service("projects_explorer")
        if projects_explorer and main_container:
            projects_explorer.close_opened_projects()

            for file_data in self.__sessions[session_name][0]:
                path, (line, col), stat_value = file_data
                if file_manager.file_exists(path):
                    mtime = os.stat(path).st_mtime
                    ignore_checkers = (mtime == stat_value)
                    main_container.open_file(path,
                                             line,
                                             col,
                                             ignore_checkers=ignore_checkers)
            if projects_explorer:
                projects_explorer.load_session_projects(
                    self.__sessions[session_name][1])
Exemple #16
0
 def _navigate_breakpoints(self, val):
     """Navigate between the breakpoints."""
     #FIXME: put navigate breakpoints and bookmarks as one method.
     breakList = list(settings.BREAKPOINTS.keys())
     breakList.sort()
     if not breakList:
         return
     if self.__breakpointsFile not in breakList:
         self.__breakpointsFile = breakList[0]
     index = breakList.index(self.__breakpointsFile)
     breaks = settings.BREAKPOINTS.get(self.__breakpointsFile, [])
     lineNumber = 0
     #val == True: forward
     if val:
         if (len(breaks) - 1) > self.__breakpointsPos:
             self.__breakpointsPos += 1
             lineNumber = breaks[self.__breakpointsPos]
         elif len(breaks) > 0:
             if index < (len(breakList) - 1):
                 self.__breakpointsFile = breakList[index + 1]
             else:
                 self.__breakpointsFile = breakList[0]
             self.__breakpointsPos = 0
             lineNumber = settings.BREAKPOINTS[self.__breakpointsFile][0]
     else:
         if self.__breakpointsPos > 0:
             self.__breakpointsPos -= 1
             lineNumber = breaks[self.__breakpointsPos]
         elif len(breaks) > 0:
             self.__breakpointsFile = breakList[index - 1]
             breaks = settings.BREAKPOINTS[self.__breakpointsFile]
             self.__breakpointsPos = len(breaks) - 1
             lineNumber = breaks[self.__breakpointsPos]
     if file_manager.file_exists(self.__breakpointsFile):
         self.open_file(self.__breakpointsFile, lineNumber, None, True)
     else:
         settings.BREAKPOINTS.pop(self.__breakpointsFile)
         if settings.BREAKPOINTS:
             self._navigate_breakpoints(val)
Exemple #17
0
 def _navigate_bookmarks(self, val):
     """Navigate between the bookmarks."""
     bookList = list(settings.BOOKMARKS.keys())
     bookList.sort()
     if not bookList:
         return
     if self.__bookmarksFile not in bookList:
         self.__bookmarksFile = bookList[0]
     index = bookList.index(self.__bookmarksFile)
     bookms = settings.BOOKMARKS.get(self.__bookmarksFile, [])
     lineNumber = 0
     # val == True: forward
     if val:
         if (len(bookms) - 1) > self.__bookmarksPos:
             self.__bookmarksPos += 1
             lineNumber = bookms[self.__bookmarksPos]
         elif len(bookms) > 0:
             if index < (len(bookList) - 1):
                 self.__bookmarksFile = bookList[index + 1]
             else:
                 self.__bookmarksFile = bookList[0]
             self.__bookmarksPos = 0
             lineNumber = settings.BOOKMARKS[self.__bookmarksFile][0]
     else:
         if self.__bookmarksPos > 0:
             self.__bookmarksPos -= 1
             lineNumber = bookms[self.__bookmarksPos]
         elif len(bookms) > 0:
             self.__bookmarksFile = bookList[index - 1]
             bookms = settings.BOOKMARKS[self.__bookmarksFile]
             self.__bookmarksPos = len(bookms) - 1
             lineNumber = bookms[self.__bookmarksPos]
     if file_manager.file_exists(self.__bookmarksFile):
         self.open_file(self.__bookmarksFile,
                        lineNumber, None, True)
     else:
         # settings.BOOKMARKS.pop(self.__bookmarksFile)
         if settings.BOOKMARKS:
             self._navigate_bookmarks(val)
Exemple #18
0
 def _navigate_bookmarks(self, val):
     """Navigate between the bookmarks."""
     bookList = list(settings.BOOKMARKS.keys())
     bookList.sort()
     if not bookList:
         return
     if self.__bookmarksFile not in bookList:
         self.__bookmarksFile = bookList[0]
     index = bookList.index(self.__bookmarksFile)
     bookms = settings.BOOKMARKS.get(self.__bookmarksFile, [])
     lineNumber = 0
     #val == True: forward
     if val:
         if (len(bookms) - 1) > self.__bookmarksPos:
             self.__bookmarksPos += 1
             lineNumber = bookms[self.__bookmarksPos]
         elif len(bookms) > 0:
             if index < (len(bookList) - 1):
                 self.__bookmarksFile = bookList[index + 1]
             else:
                 self.__bookmarksFile = bookList[0]
             self.__bookmarksPos = 0
             lineNumber = settings.BOOKMARKS[self.__bookmarksFile][0]
     else:
         if self.__bookmarksPos > 0:
             self.__bookmarksPos -= 1
             lineNumber = bookms[self.__bookmarksPos]
         elif len(bookms) > 0:
             self.__bookmarksFile = bookList[index - 1]
             bookms = settings.BOOKMARKS[self.__bookmarksFile]
             self.__bookmarksPos = len(bookms) - 1
             lineNumber = bookms[self.__bookmarksPos]
     if file_manager.file_exists(self.__bookmarksFile):
         self.open_file(self.__bookmarksFile,
             lineNumber, None, True)
     else:
         settings.BOOKMARKS.pop(self.__bookmarksFile)
         if settings.BOOKMARKS:
             self._navigate_bookmarks(val)
Exemple #19
0
 def _navigate_breakpoints(self, val):
     """Navigate between the breakpoints."""
     # FIXME: put navigate breakpoints and bookmarks as one method.
     breakList = list(settings.BREAKPOINTS.keys())
     breakList.sort()
     if not breakList:
         return
     if self.__breakpointsFile not in breakList:
         self.__breakpointsFile = breakList[0]
     index = breakList.index(self.__breakpointsFile)
     breaks = settings.BREAKPOINTS.get(self.__breakpointsFile, [])
     lineNumber = 0
     # val == True: forward
     if val:
         if (len(breaks) - 1) > self.__breakpointsPos:
             self.__breakpointsPos += 1
             lineNumber = breaks[self.__breakpointsPos]
         elif len(breaks) > 0:
             if index < (len(breakList) - 1):
                 self.__breakpointsFile = breakList[index + 1]
             else:
                 self.__breakpointsFile = breakList[0]
             self.__breakpointsPos = 0
             lineNumber = settings.BREAKPOINTS[self.__breakpointsFile][0]
     else:
         if self.__breakpointsPos > 0:
             self.__breakpointsPos -= 1
             lineNumber = breaks[self.__breakpointsPos]
         elif len(breaks) > 0:
             self.__breakpointsFile = breakList[index - 1]
             breaks = settings.BREAKPOINTS[self.__breakpointsFile]
             self.__breakpointsPos = len(breaks) - 1
             lineNumber = breaks[self.__breakpointsPos]
     if file_manager.file_exists(self.__breakpointsFile):
         self.open_file(self.__breakpointsFile, lineNumber, None, True)
     else:
         settings.BREAKPOINTS.pop(self.__breakpointsFile)
         if settings.BREAKPOINTS:
             self._navigate_breakpoints(val)
Exemple #20
0
 def load_session_files_projects(self,
                                 files,
                                 projects,
                                 current_file,
                                 recent_files=None):
     """Load the files and projects from previous session."""
     main_container = IDE.get_service('main_container')
     projects_explorer = IDE.get_service('projects_explorer')
     if main_container and files:
         #self.connect(explorer, SIGNAL("projectOpened(QString)"),
         #self._set_editors_project_data)
         for fileData in files:
             if file_manager.file_exists(fileData[0]):
                 mtime = os.stat(fileData[0]).st_mtime
                 ignore_checkers = (mtime == fileData[2])
                 main_container.open_file(fileData[0],
                                          fileData[1],
                                          ignore_checkers=ignore_checkers)
         if current_file:
             main_container.open_file(current_file)
     if projects_explorer and projects:
         projects_explorer.load_session_projects(projects)
Exemple #21
0
 def save_project_properties(self):
     # save project properties
     project = {}
     project['name'] = self._name
     project['description'] = self.description
     project['url'] = self.url
     project['license'] = self.license
     project['mainFile'] = self.main_file
     project['project-type'] = self.project_type
     project['supported-extensions'] = self.extensions
     project['indentation'] = self.indentation
     project['use-tabs'] = self.use_tabs
     project['pythonExec'] = self.python_exec  # FIXME
     project['PYTHONPATH'] = self.python_path
     project['additional_builtins'] = self.additional_builtins
     project['preExecScript'] = self.pre_exec_script
     project['postExecScript'] = self.post_exec_script
     project['venv'] = self.venv
     project['programParams'] = self.program_params
     project['relatedProjects'] = self.related_projects
     if file_manager.file_exists(self.path, self._name + '.nja'):
         file_manager.delete_file(self.path, self._name + '.nja')
     json_manager.create_ninja_project(self.path, self._name, project)
Exemple #22
0
 def save_project_properties(self):
     #save project properties
     project = {}
     project['name'] = self._name
     project['description'] = self.description
     project['url'] = self.url
     project['license'] = self.license
     project['mainFile'] = self.main_file
     project['project-type'] = self.project_type
     project['supported-extensions'] = self.extensions
     project['indentation'] = self.indentation
     project['use-tabs'] = self.use_tabs
     project['pythonExec'] = self.python_exec  # FIXME
     project['PYTHONPATH'] = self.python_path
     project['additional_builtins'] = self.additional_builtins
     project['preExecScript'] = self.pre_exec_script
     project['postExecScript'] = self.post_exec_script
     project['venv'] = self.venv
     project['programParams'] = self.program_params
     project['relatedProjects'] = self.related_projects
     if file_manager.file_exists(self.path, self._name + '.nja'):
         file_manager.delete_file(self.path, self._name + '.nja')
     json_manager.create_ninja_project(self.path, self._name, project)
Exemple #23
0
def start_ide(app, filenames, projects_path, extra_plugins, linenos):
    """Load all the settings necessary before loading the UI, and start IDE."""
    QCoreApplication.setOrganizationName('NINJA-IDE')
    QCoreApplication.setOrganizationDomain('NINJA-IDE')
    QCoreApplication.setApplicationName('NINJA-IDE')
    app.setWindowIcon(QIcon(":img/icon"))

    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    running = ipc.is_running()
    start_server = not running[0]
    if running[0] and (filenames or projects_path):
        sended = ipc.send_data(running[1], filenames, projects_path, linenos)
        running[1].close()
        if sended:
            sys.exit()
    else:
        running[1].close()

    # Create and display the splash screen
    splash_pix = QPixmap(":img/splash")
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Set the cursor to unblinking
    #if not settings.IS_WINDOWS:
    #app.setCursorFlashTime(0)

    #Set the codec for strings (QString)
    QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8'))

    #Translator
    qsettings = ide.IDE.ninja_settings()
    data_qsettings = ide.IDE.data_settings()
    language = QLocale.system().name()
    lang = qsettings.value('preferences/interface/language',
                           defaultValue=language,
                           type='QString') + '.qm'
    lang_path = file_manager.create_path(resources.LANGS, lang)
    if file_manager.file_exists(lang_path):
        settings.LANGUAGE = lang_path
    translator = QTranslator()
    if settings.LANGUAGE:
        translator.load(settings.LANGUAGE)
        app.installTranslator(translator)

        qtTranslator = QTranslator()
        qtTranslator.load("qt_" + language,
                          QLibraryInfo.location(QLibraryInfo.TranslationsPath))
        app.installTranslator(qtTranslator)

    #Loading Syntax
    splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
    json_manager.load_syntax()

    #Read Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop,
                       Qt.black)

    #Set Stylesheet
    style_applied = False
    print(settings.NINJA_SKIN)
    if settings.NINJA_SKIN not in ('Default'):
        file_name = ("%s.qss" % settings.NINJA_SKIN)
        qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD,
                                            file_name)
        if file_manager.file_exists(qss_file):
            with open(qss_file) as fileaccess:
                qss = fileaccess.read()
                app.setStyleSheet(qss)
                style_applied = True
    if not style_applied:
        if settings.NINJA_SKIN == 'Default':
            with open(resources.NINJA_THEME) as fileaccess:
                qss = fileaccess.read()
        app.setStyleSheet(qss)

    #Loading Schemes
    splash.showMessage("Loading Schemes", Qt.AlignRight | Qt.AlignTop,
                       Qt.black)
    scheme = qsettings.value('preferences/editor/scheme',
                             "default",
                             type='QString')
    if scheme != 'default':
        scheme = file_manager.create_path(resources.EDITOR_SKINS,
                                          scheme + '.color')
        if file_manager.file_exists(scheme):
            resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))

    #Loading Shortcuts
    resources.load_shortcuts()
    #Loading GUI
    splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
    ninjaide = ide.IDE(start_server)

    #Showing GUI
    ninjaide.show()
    #OSX workaround for ninja window not in front
    try:
        ninjaide.raise_()
    except:
        pass  # I really dont mind if this fails in any form
    #Loading Session Files
    splash.showMessage("Loading Files and Projects",
                       Qt.AlignRight | Qt.AlignTop, Qt.black)

    #First check if we need to load last session files
    if qsettings.value('preferences/general/loadFiles', True, type=bool):
        #Files in Main Tab
        files = data_qsettings.value('lastSession/openedFiles', [])
        tempFiles = []
        if files:
            for file_ in files:
                fileData = tuple(file_)
                if fileData:
                    tempFiles.append(fileData)
        files = tempFiles

        # Recent Files
        recent_files = data_qsettings.value('lastSession/recentFiles', [])
        #Current File
        current_file = data_qsettings.value('lastSession/currentFile',
                                            '',
                                            type='QString')
        #Projects
        projects = data_qsettings.value('lastSession/projects', [])
    else:
        files = []
        recent_files = []
        current_file = ''
        projects = []

    #Include files received from console args
    file_with_nro = list([(f[0], (f[1] - 1, 0), 0)
                          for f in zip(filenames, linenos)])
    file_without_nro = list([(f, (0, 0), 0) for f in filenames[len(linenos):]])
    files += file_with_nro + file_without_nro
    #Include projects received from console args
    if projects_path:
        projects += projects_path
    #FIXME: IMPROVE THIS WITH THE NEW WAY OF DO IT
    ninjaide.load_session_files_projects(files, projects, current_file,
                                         recent_files)
    #Load external plugins
    #if extra_plugins:
    #ninjaide.load_external_plugins(extra_plugins)

    splash.finish(ninjaide)
    ninjaide.notify_plugin_errors()
    ninjaide.show_python_detection()
Exemple #24
0
 def open_files(self, files):
     for fileData in files:
         if file_manager.file_exists(fileData[0]):
             self.open_file(fileData[0], fileData[1])
Exemple #25
0
def start_ide(app, filenames, projects_path, extra_plugins, linenos):
    """Load all the settings necessary before loading the UI, and start IDE."""
    QCoreApplication.setOrganizationName('NINJA-IDE')
    QCoreApplication.setOrganizationDomain('NINJA-IDE')
    QCoreApplication.setApplicationName('NINJA-IDE')
    app.setWindowIcon(QIcon(":img/icon"))

    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    running = ipc.is_running()
    start_server = not running[0]
    if running[0] and (filenames or projects_path):
        sended = ipc.send_data(running[1], filenames, projects_path, linenos)
        running[1].close()
        if sended:
            sys.exit()
    else:
        running[1].close()

    # Create and display the splash screen
    splash_pix = QPixmap(":img/splash")
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Set the cursor to unblinking
    if not settings.IS_WINDOWS:
        app.setCursorFlashTime(0)

    #Set the codec for strings (QString)
    QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8'))

    #Translator
    qsettings = ide.IDE.ninja_settings()
    data_qsettings = ide.IDE.data_settings()
    language = QLocale.system().name()
    lang = qsettings.value('preferences/interface/language',
        defaultValue=language, type='QString') + '.qm'
    lang_path = file_manager.create_path(resources.LANGS, lang)
    if file_manager.file_exists(lang_path):
        settings.LANGUAGE = lang_path
    translator = QTranslator()
    if settings.LANGUAGE:
        translator.load(settings.LANGUAGE)
        app.installTranslator(translator)

        qtTranslator = QTranslator()
        qtTranslator.load("qt_" + language,
            QLibraryInfo.location(QLibraryInfo.TranslationsPath))
        app.installTranslator(qtTranslator)

    #Loading Syntax
    splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
    json_manager.load_syntax()

    #Read Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop,
        Qt.black)
    settings.load_settings()

    #Set Stylesheet
    style_applied = False
    if settings.NINJA_SKIN not in ('Default', 'Classic Theme'):
        file_name = ("%s.qss" % settings.NINJA_SKIN)
        qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD,
            file_name)
        if file_manager.file_exists(qss_file):
            with open(qss_file) as f:
                qss = f.read()
                app.setStyleSheet(qss)
                style_applied = True
    if not style_applied:
        if settings.NINJA_SKIN == 'Default':
            with open(resources.NINJA_THEME) as f:
                qss = f.read()
        else:
            with open(resources.NINJA_THEME_CLASSIC) as f:
                qss = f.read()
        app.setStyleSheet(qss)

    #Loading Schemes
    splash.showMessage("Loading Schemes",
        Qt.AlignRight | Qt.AlignTop, Qt.black)
    scheme = qsettings.value('preferences/editor/scheme', "default",
        type='QString')
    if scheme != 'default':
        scheme = file_manager.create_path(resources.EDITOR_SKINS,
            scheme + '.color')
        if file_manager.file_exists(scheme):
            resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))

    #Loading Shortcuts
    resources.load_shortcuts()
    #Loading GUI
    splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
    ninjaide = ide.IDE(start_server)

    #Showing GUI
    ninjaide.show()
    #OSX workaround for ninja window not in front
    try:
        ninjaide.raise_()
    except:
        pass  # I really dont mind if this fails in any form
    #Loading Session Files
    splash.showMessage("Loading Files and Projects",
        Qt.AlignRight | Qt.AlignTop, Qt.black)

    #First check if we need to load last session files
    if qsettings.value('preferences/general/loadFiles', True, type=bool):
        #Files in Main Tab
        files = data_qsettings.value('lastSession/openedFiles', [])
        tempFiles = []
        if files:
            for file_ in files:
                fileData = tuple(file_)
                if fileData:
                    tempFiles.append(fileData)
        files = tempFiles

        # Recent Files
        recent_files = data_qsettings.value('lastSession/recentFiles', [])
        #Current File
        current_file = data_qsettings.value(
                        'lastSession/currentFile', '', type='QString')
        #Projects
        projects = data_qsettings.value('lastSession/projects', [])
    else:
        files = []
        recent_files = []
        current_file = ''
        projects = []

    #Include files received from console args
    file_with_nro = list([(f[0], f[1] - 1) for f in zip(filenames, linenos)])
    file_without_nro = list([(f, 0) for f in filenames[len(linenos):]])
    files += file_with_nro + file_without_nro
    #Include projects received from console args
    if projects_path:
        projects += projects_path
    #FIXME: IMPROVE THIS WITH THE NEW WAY OF DO IT
    ninjaide.load_session_files_projects(files, projects,
                                         current_file, recent_files)
    #Load external plugins
    #if extra_plugins:
        #ninjaide.load_external_plugins(extra_plugins)

    splash.finish(ninjaide)
    ninjaide.notify_plugin_errors()
    ninjaide.show_python_detection()
Exemple #26
0
def start_ide(app, filenames, projects_path, extra_plugins, linenos):
    """Load all the settings necessary before loading the UI, and start IDE."""
    QCoreApplication.setOrganizationName("NINJA-IDE")
    QCoreApplication.setOrganizationDomain("NINJA-IDE")
    QCoreApplication.setApplicationName("NINJA-IDE")
    app.setWindowIcon(QIcon(resources.IMAGES["icon"]))

    # Check if there is another session of ninja-ide opened
    # and in that case send the filenames and projects to that session
    running = ipc.is_running()
    start_server = not running[0]
    if running[0] and (filenames or projects_path):
        sended = ipc.send_data(running[1], filenames, projects_path, linenos)
        running[1].close()
        if sended:
            sys.exit()
    else:
        running[1].close()

    # Create and display the splash screen
    splash_pix = QPixmap(resources.IMAGES["splash"])
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()

    # Set the cursor to unblinking
    if not settings.IS_WINDOWS:
        app.setCursorFlashTime(0)

    # Set the codec for strings (QString)
    QTextCodec.setCodecForCStrings(QTextCodec.codecForName("utf-8"))

    # Translator
    qsettings = QSettings(resources.SETTINGS_PATH, QSettings.IniFormat)
    language = QLocale.system().name()
    lang = qsettings.value("preferences/interface/language", defaultValue=language, type="QString") + ".qm"
    lang_path = file_manager.create_path(resources.LANGS, lang)
    if file_manager.file_exists(lang_path):
        settings.LANGUAGE = lang_path
    translator = QTranslator()
    if settings.LANGUAGE:
        translator.load(settings.LANGUAGE)
        app.installTranslator(translator)

        qtTranslator = QTranslator()
        qtTranslator.load("qt_" + language, QLibraryInfo.location(QLibraryInfo.TranslationsPath))
        app.installTranslator(qtTranslator)

    # Loading Syntax
    splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
    json_manager.load_syntax()

    # Read Settings
    splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop, Qt.black)
    settings.load_settings()

    # Set Stylesheet
    style_applied = False
    if settings.NINJA_SKIN not in ("Default", "Classic Theme"):
        file_name = "%s.qss" % settings.NINJA_SKIN
        qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD, file_name)
        if file_manager.file_exists(qss_file):
            with open(qss_file) as f:
                qss = f.read()
                app.setStyleSheet(qss)
                style_applied = True
    if not style_applied:
        if settings.NINJA_SKIN == "Default":
            with open(resources.NINJA_THEME) as f:
                qss = f.read()
        else:
            with open(resources.NINJA_THEME_CLASSIC) as f:
                qss = f.read()
        app.setStyleSheet(qss)

    # Loading Schemes
    splash.showMessage("Loading Schemes", Qt.AlignRight | Qt.AlignTop, Qt.black)
    scheme = qsettings.value("preferences/editor/scheme", "default", type="QString")
    if scheme != "default":
        scheme = file_manager.create_path(resources.EDITOR_SKINS, scheme + ".color")
        if file_manager.file_exists(scheme):
            resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))

    # Loading Shortcuts
    resources.load_shortcuts()
    # Loading GUI
    splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
    ninjaide = ide.IDE(start_server)

    # Showing GUI
    ninjaide.show()

    # Loading Session Files
    splash.showMessage("Loading Files and Projects", Qt.AlignRight | Qt.AlignTop, Qt.black)

    # First check if we need to load last session files
    if qsettings.value("preferences/general/loadFiles", True, type=bool):
        # Files in Main Tab
        main_files = qsettings.value("openFiles/mainTab", [])
        tempFiles = []
        if main_files:
            for file_ in main_files:
                fileData = list(file_)
                if fileData:
                    lineno = fileData[1]
                    tempFiles.append((fileData[0], lineno))
        main_files = tempFiles
        # Files in Secondary Tab
        sec_files = qsettings.value("openFiles/secondaryTab", [])
        tempFiles = []
        if sec_files:
            for file_ in sec_files:
                fileData = list(file_)
                if fileData:
                    lineno = fileData[1]
                    tempFiles.append((fileData[0], lineno))
        sec_files = tempFiles

        # Recent Files
        recent_files = qsettings.value("openFiles/recentFiles", [])
        # Current File
        current_file = qsettings.value("openFiles/currentFile", "", type="QString")
        # Projects
        projects = qsettings.value("openFiles/projects", [])
    else:
        main_files = []
        sec_files = []
        recent_files = []
        current_file = ""
        projects = []

    # Include files received from console args
    file_with_nro = list([(f[0], f[1] - 1) for f in zip(filenames, linenos)])
    file_without_nro = list([(f, 0) for f in filenames[len(linenos) :]])
    main_files += file_with_nro + file_without_nro
    # Include projects received from console args
    if projects_path:
        projects += projects_path
    # FIXME: IMPROVE THIS WITH THE NEW WAY OF DO IT
    # ninjaide.load_session_files_projects(main_files, sec_files,
    # projects, current_file, recent_files)
    # Load external plugins
    # if extra_plugins:
    # ninjaide.load_external_plugins(extra_plugins)

    splash.finish(ninjaide)
    ninjaide.notify_plugin_errors()
    ninjaide.show_python_detection()
Exemple #27
0
 def open_files(self, files):
     for fileData in files:
         if file_manager.file_exists(fileData[0]):
             self.open_file(fileData[0], fileData[1])