Example #1
0
    def expand_tab_name(self, title):
        """Expand the tab title to differentiate files with the same name.

        The way it is currently implemented, it will only change the first
        conflicting title passed in, because it only searches until the new
        title isn't in the tab titles.
        """
        if title == 'New Document':
            return
        elif title not in self.titles:
            self.titles.append(title)
            return
        indexes = [
            i for i in range(self.count())
            if type(self.widget(i)) is editor.Editor
            and self.tabText(i) == title and self.widget(i).ID
        ]  # self.widget.ID returns the basename
        self.dontLoopInExpandTitle = True
        for i in indexes:
            newName = file_manager.create_path(
                file_manager.get_basename(
                    file_manager.get_folder(self.widget(i).ID)), title)
            while newName in self.titles:
                # Keep prepending the folder name onto the title until it
                # does not conflict.
                path = self.widget(i).ID
                tempDir = path[:path.rfind(newName)]
                newName = file_manager.create_path(
                    file_manager.get_basename(
                        file_manager.get_folder(tempDir)), '..', title)
            self.titles.append(newName)
            self.setTabText(i, newName)
        self.dontLoopInExpandTitle = False
Example #2
0
    def expand_tab_name(self, title):
        """Expand the tab title to differentiate files with the same name.

        The way it is currently implemented, it will only change the first
        conflicting title passed in, because it only searches until the new
        title isn't in the tab titles.
        """
        if title == 'New Document':
            return
        elif title not in self.titles:
            self.titles.append(title)
            return
        indexes = [i for i in range(self.count())
            if type(self.widget(i)) is editor.Editor and
            self.tabText(i) == title and
            self.widget(i).ID]  # self.widget.ID returns the basename
        self.dontLoopInExpandTitle = True
        for i in indexes:
            newName = file_manager.create_path(
                file_manager.get_basename(
                    file_manager.get_folder(self.widget(i).ID)), title)
            while newName in self.titles:
                # Keep prepending the folder name onto the title until it
                # does not conflict.
                path = self.widget(i).ID
                tempDir = path[:path.rfind(newName)]
                newName = file_manager.create_path(
                    file_manager.get_basename(
                        file_manager.get_folder(tempDir)),
                    '..',
                    title)
            self.titles.append(newName)
            self.setTabText(i, newName)
        self.dontLoopInExpandTitle = False
Example #3
0
    def execute_project(self):
        """Execute the project marked as Main Project."""

        projects_explorer = IDE.get_service("projects_explorer")
        if projects_explorer is None:
            return
        nproject = projects_explorer.current_project
        if nproject:
            main_file = nproject.main_file
            if not main_file:
                # Open project properties to specify the main file
                projects_explorer.current_tree.open_project_properties()
            else:
                # Save project files
                projects_explorer.save_project()
                # Emit a signal for plugin!
                self.projectExecuted.emit(nproject.path)

                main_file = file_manager.create_path(
                    nproject.path, nproject.main_file)
                self.start_process(
                    filename=main_file,
                    python_exec=nproject.python_exec,
                    pre_exec_script=nproject.pre_exec_script,
                    post_exec_script=nproject.post_exec_script,
                    program_params=nproject.program_params
                )
    def execute_project(self):
        """Execute the project marked as Main Project."""
        projects_explorer = IDE.get_service('projects_explorer')
        if projects_explorer is None:
            return
        nproject = projects_explorer.current_project
        if nproject:
            main_file = nproject.main_file
            if not main_file and projects_explorer.current_tree:
                projects_explorer.current_tree.open_project_properties()
            elif main_file:
                projects_explorer.save_project()
                #emit a signal for plugin!
                self.projectExecuted.emit(nproject.path)

                main_file = file_manager.create_path(nproject.path,
                                                     nproject.main_file)
                self._run_application(
                    main_file,
                    pythonExec=nproject.python_exec_command,
                    PYTHONPATH=nproject.python_path,
                    programParams=nproject.program_params,
                    preExec=nproject.pre_exec_script,
                    postExec=nproject.post_exec_script)
        else:
            QMessageBox.information(self, translations.TR_INFO_TITLE_PROJECT_PROPERTIES,
                translations.TR_INFO_MESSAGE_PROJECT_PROPERTIES)
Example #5
0
    def _replace_results(self):
        """Replace the search with the proper text in all the files."""
        result = QMessageBox.question(
            self,
            translations.TR_REPLACE_FILES_CONTENTS,
            translations.TR_ARE_YOU_SURE_WANT_TO_REPLACE,
            buttons=QMessageBox.Yes | QMessageBox.No)
        if result == QMessageBox.Yes:
            for index in range(self._result_widget.topLevelItemCount()):
                parent = self._result_widget.topLevelItem(index)
                root_dir_name = parent.dir_name_root
                file_name = parent.text(0)
                file_path = file_manager.create_path(root_dir_name, file_name)
                try:
                    content = file_manager.read_file_content(file_path)
                    pattern = self._find_widget.pattern_line_edit.text()
                    flags = 0
                    if not self._find_widget.case_checkbox.isChecked():
                        flags |= re.IGNORECASE
                    if self._find_widget.type_checkbox.isChecked():
                        pattern = r'\b%s\b' % pattern

                    new_content = re.sub(pattern,
                                         self._find_widget.replace_line.text(),
                                         content,
                                         flags=flags)
                    file_manager.store_file_content(file_path, new_content,
                                                    False)
                except:
                    print(('File: {} content, could not be replaced'.format(
                        file_path)))
 def _add_file_to_project(self, path):
     """Add the file for 'path' in the project the user choose here."""
     if self._projects_area.count() > 0:
         pathProject = [self.current_project]
         addToProject = add_to_project.AddToProject(pathProject, self)
         addToProject.exec_()
         if not addToProject.pathSelected:
             return
         main_container = IDE.get_service('main_container')
         if not main_container:
             return
         editorWidget = main_container.get_current_editor()
         if not editorWidget.file_path:
             name = QInputDialog.getText(
                 None, translations.TR_ADD_FILE_TO_PROJECT,
                 translations.TR_FILENAME + ": ")[0]
             if not name:
                 QMessageBox.information(
                     self, translations.TR_INVALID_FILENAME,
                     translations.TR_INVALID_FILENAME_ENTER_A_FILENAME)
                 return
         else:
             name = file_manager.get_basename(editorWidget.file_path)
         new_path = file_manager.create_path(addToProject.pathSelected,
                                             name)
         ide_srv = IDE.get_service("ide")
         old_file = ide_srv.get_or_create_nfile(path)
         new_file = old_file.save(editorWidget.text(), new_path)
         # FIXME: Make this file replace the original in the open tab
     else:
         pass
 def delete_theme(self):
     if self.list_skins.currentRow() != 0:
         file_name = ("%s.qss" % self.list_skins.currentItem().text())
         qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD,
                                             file_name)
         file_manager.delete_file(qss_file)
         self._refresh_list()
 def _copy_file(self):
     #get the selected QTreeWidgetItem
     item = self.currentItem()
     if item.parent() is None:
         pathForFile = item.path
     else:
         pathForFile = os.path.join(item.path, item.text(0))
     pathProjects = [p.path for p in self.get_open_projects()]
     addToProject = ui_tools.AddToProject(pathProjects, self)
     addToProject.setWindowTitle(self.tr("Copy File to"))
     addToProject.exec_()
     if not addToProject.pathSelected:
         return
     name = QInputDialog.getText(self,
                                 self.tr("Copy File"),
                                 self.tr("File Name:"),
                                 text=item.text(0))[0]
     if not name:
         QMessageBox.information(
             self, self.tr("Invalid Name"),
             self.tr("The file name is empty, please enter a name"))
         return
     path = file_manager.create_path(addToProject.pathSelected, name)
     try:
         content = file_manager.read_file_content(pathForFile)
         path = file_manager.store_file_content(path, content, newFile=True)
         self.add_existing_file(path)
     except file_manager.NinjaFileExistsException as ex:
         QMessageBox.information(
             self, self.tr("File Already Exists"),
             (self.tr("Invalid Path: the file '%s' already exists.") %
              ex.filename))
 def _rename_file(self):
     path = self.model().filePath(self.currentIndex())
     name = file_manager.get_basename(path)
     new_name, ok = QInputDialog.getText(self,
                                         translations.TR_RENAME_FILE,
                                         translations.TR_ENTER_NEW_FILENAME,
                                         text=name)
     if ok and new_name.strip():
         filename = file_manager.create_path(file_manager.get_folder(path),
                                             new_name)
         if path == filename:
             return
         ninjaide = IDE.get_service("ide")
         print(ninjaide.filesystem.get_files())
         current_nfile = ninjaide.get_or_create_nfile(path)
         editable = ninjaide.get_editable(nfile=current_nfile)
         current_nfile.move(filename)
         if editable is not None:
             main_container = IDE.get_service("main_container")
             main_container.combo_area.bar.update_item_text(
                 editable, new_name)
             tree = ninjaide.filesystem.get_files()
             # FIXME: this is bad
             tree[filename] = tree.pop(path)
         print(ninjaide.filesystem.get_files())
Example #10
0
 def _add_file_to_project(self, path):
     """Add the file for 'path' in the project the user choose here."""
     if self._active_project:
         pathProject = [self._active_project.project]
         addToProject = add_to_project.AddToProject(pathProject, self)
         addToProject.exec_()
         if not addToProject.pathSelected:
             return
         main_container = IDE.get_service('main_container')
         if not main_container:
             return
         editorWidget = main_container.get_current_editor()
         if not editorWidget.file_path:
             name = QInputDialog.getText(None,
                                         translations.TR_ADD_FILE_TO_PROJECT,
                                         translations.TR_FILENAME + ": ")[0]
             if not name:
                 QMessageBox.information(
                     self,
                     translations.TR_INVALID_FILENAME,
                     translations.TR_INVALID_FILENAME_ENTER_A_FILENAME)
                 return
         else:
             name = file_manager.get_basename(editorWidget.file_path)
         new_path = file_manager.create_path(addToProject.pathSelected, name)
         ide_srv = IDE.get_service("ide")
         old_file = ide_srv.get_or_create_nfile(path)
         new_file = old_file.save(editorWidget.get_text(), new_path)
         #FIXME: Make this file replace the original in the open tab
     else:
         pass
 def _copy_file(self):
     path = self.model().filePath(self.currentIndex())
     name = file_manager.get_basename(path)
     global projectsColumn
     pathProjects = [p.project for p in projectsColumn.projects]
     add_to_project_dialog = add_to_project.AddToProject(pathProjects, self)
     add_to_project_dialog.setWindowTitle(translations.TR_COPY_FILE_TO)
     add_to_project_dialog.exec_()
     if not add_to_project_dialog.path_selected:
         return
     name = QInputDialog.getText(self,
                                 translations.TR_COPY_FILE,
                                 translations.TR_FILENAME,
                                 text=name)[0]
     if not name:
         QMessageBox.information(
             self, translations.TR_INVALID_FILENAME,
             translations.TR_INVALID_FILENAME_ENTER_A_FILENAME)
         return
     new_path = file_manager.create_path(add_to_project_dialog.pathSelected,
                                         name)
     ninjaide = IDE.get_service("ide")
     current_nfile = ninjaide.get_or_create_nfile(path)
     # FIXME: Catch willOverWrite and willCopyTo signals
     current_nfile.copy(new_path)
Example #12
0
    def _replace_results(self):
        result = QMessageBox.question(
            self,
            self.tr("Replace Files Contents"),
            self.tr("Are you sure you want to replace the content in "
                    "this files?\n(The change is not reversible)"),
            buttons=QMessageBox.Yes | QMessageBox.No)
        if result == QMessageBox.Yes:
            for index in range(self._result_widget.topLevelItemCount()):
                parent = self._result_widget.topLevelItem(index)
                root_dir_name = parent.dir_name_root
                file_name = parent.text(0)
                file_path = file_manager.create_path(root_dir_name, file_name)
                try:
                    content = file_manager.read_file_content(file_path)
                    pattern = self._find_widget.pattern_line_edit.text()
                    flags = 0
                    if not self._find_widget.case_checkbox.isChecked():
                        flags |= re.IGNORECASE
                    if self._find_widget.type_checkbox.isChecked():
                        pattern = r'\b%s\b' % pattern

                    new_content = re.sub(pattern,
                                         self._find_widget.replace_line.text(),
                                         content,
                                         flags=flags)
                    file_manager.store_file_content(file_path, new_content,
                                                    False)
                except:
                    print('File: %s content, could not be replaced' %
                          file_path)
    def execute_project(self):
        """Execute the project marked as Main Project."""
        projects_explorer = IDE.get_service('projects_explorer')
        if projects_explorer is None:
            return
        nproject = projects_explorer.current_project
        if nproject:
            main_file = nproject.main_file
            if not main_file and projects_explorer.current_tree:
                projects_explorer.current_tree.open_project_properties()
            elif main_file:
                projects_explorer.save_project()
                #emit a signal for plugin!
                self.projectExecuted.emit(nproject.path)

                main_file = file_manager.create_path(nproject.path,
                                                     nproject.main_file)
                self._run_application(main_file,
                                      pythonExec=nproject.python_exec_command,
                                      PYTHONPATH=nproject.python_path,
                                      programParams=nproject.program_params,
                                      preExec=nproject.pre_exec_script,
                                      postExec=nproject.post_exec_script)
        else:
            QMessageBox.information(
                self, translations.TR_INFO_TITLE_PROJECT_PROPERTIES,
                translations.TR_INFO_MESSAGE_PROJECT_PROPERTIES)
 def _add_file_to_project(self, path):
     """Add the file for 'path' in the project the user choose here."""
     if self._active_project:
         pathProject = [self._active_project.project]
         addToProject = add_to_project.AddToProject(pathProject, self)
         addToProject.exec_()
         if not addToProject.pathSelected:
             return
         main_container = IDE.get_service('main_container')
         if not main_container:
             return
         editorWidget = main_container.get_current_editor()
         if not editorWidget.file_path:
             name = QInputDialog.getText(None,
                 self.tr("Add File To Project"), self.tr("File Name:"))[0]
             if not name:
                 QMessageBox.information(self, self.tr("Invalid Name"),
                     self.tr("The file name is empty, please enter a name"))
                 return
         else:
             name = file_manager.get_basename(editorWidget.file_path)
         new_path = file_manager.create_path(addToProject.pathSelected, name)
         ide_srv = IDE.get_service("ide")
         old_file, ide_srv.get_or_create_nfile(path)
         new_file = old_file.save(editorWidget.get_text(), path)
         #FIXME: Make this file replace the original in the open tab
     else:
         pass
Example #15
0
 def _move_file(self):
     item = self.currentItem()
     if item.parent() is None:
         pathForFile = item.path
     else:
         pathForFile = os.path.join(item.path, item.text(0))
     pathProjects = [p.path for p in self.get_open_projects()]
     addToProject = ui_tools.AddToProject(pathProjects, self)
     addToProject.setWindowTitle(self.tr("Copy File to"))
     addToProject.exec_()
     if not addToProject.pathSelected:
         return
     name = file_manager.get_basename(pathForFile)
     path = file_manager.create_path(addToProject.pathSelected, name)
     try:
         content = file_manager.read_file_content(pathForFile)
         path = file_manager.store_file_content(path, content, newFile=True)
         file_manager.delete_file(pathForFile)
         index = item.parent().indexOfChild(item)
         item.parent().takeChild(index)
         self.add_existing_file(path)
         # Update path of opened file
         main = IDE.get_service('main_container')
         if main and main.is_open(pathForFile):
             widget = main.get_widget_for_path(pathForFile)
             if widget:
                 widget.ID = path
     except file_manager.NinjaFileExistsException as ex:
             QMessageBox.information(self, self.tr("File Already Exists"),
                 (self.tr("Invalid Path: the file '%s' already exists.") %
                     ex.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))
Example #17
0
 def _copy_file(self):
     #get the selected QTreeWidgetItem
     item = self.currentItem()
     if item.parent() is None:
         pathForFile = item.path
     else:
         pathForFile = os.path.join(item.path, item.text(0))
     pathProjects = [p.path for p in self.get_open_projects()]
     addToProject = ui_tools.AddToProject(pathProjects, self)
     addToProject.setWindowTitle(self.tr("Copy File to"))
     addToProject.exec_()
     if not addToProject.pathSelected:
         return
     name = QInputDialog.getText(self, self.tr("Copy File"),
         self.tr("File Name:"), text=item.text(0))[0]
     if not name:
         QMessageBox.information(self, self.tr("Invalid Name"),
             self.tr("The file name is empty, please enter a name"))
         return
     path = file_manager.create_path(addToProject.pathSelected, name)
     try:
         content = file_manager.read_file_content(pathForFile)
         path = file_manager.store_file_content(path, content, newFile=True)
         self.add_existing_file(path)
     except file_manager.NinjaFileExistsException as ex:
             QMessageBox.information(self, self.tr("File Already Exists"),
                 (self.tr("Invalid Path: the file '%s' already exists.") %
                     ex.filename))
Example #18
0
 def _remove_scheme(self):
     name = self._listScheme.currentItem().text()
     fileName = ('{0}.color'.format(
         file_manager.create_path(resources.EDITOR_SKINS, name)))
     file_manager.delete_file(fileName)
     item = self._listScheme.takeItem(self._listScheme.currentRow())
     del item
Example #19
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 _copy_file(self):
     #get the selected QTreeWidgetItem
     path = self.model().filePath(self.currentIndex())
     name = file_manager.get_basename(path)
     global projectsColumn
     pathProjects = [p.path for p in projectsColumn.projects]
     addToProject = add_to_project.AddToProject(pathProjects, self)
     addToProject.setWindowTitle(self.tr("Copy File to"))
     addToProject.exec_()
     if not addToProject.pathSelected:
         return
     name = QInputDialog.getText(self, self.tr("Copy File"),
         self.tr("File Name:"), text=name)[0]
     if not name:
         QMessageBox.information(self, self.tr("Invalid Name"),
             self.tr("The file name is empty, please enter a name"))
         return
     path = file_manager.create_path(addToProject.pathSelected, name)
     try:
         content = file_manager.read_file_content(path)
         path = file_manager.store_file_content(path, content, newFile=True)
     except file_manager.NinjaFileExistsException as ex:
             QMessageBox.information(self, self.tr("File Already Exists"),
                 (self.tr("Invalid Path: the file '%s' already exists.") %
                     ex.filename))
 def _move_file(self):
     item = self.currentItem()
     if item.parent() is None:
         pathForFile = item.path
     else:
         pathForFile = os.path.join(item.path, item.text(0))
     pathProjects = [p.path for p in self.get_open_projects()]
     addToProject = ui_tools.AddToProject(pathProjects, self)
     addToProject.setWindowTitle(self.tr("Copy File to"))
     addToProject.exec_()
     if not addToProject.pathSelected:
         return
     name = file_manager.get_basename(pathForFile)
     path = file_manager.create_path(addToProject.pathSelected, name)
     try:
         content = file_manager.read_file_content(pathForFile)
         path = file_manager.store_file_content(path, content, newFile=True)
         file_manager.delete_file(pathForFile)
         index = item.parent().indexOfChild(item)
         item.parent().takeChild(index)
         self.add_existing_file(path)
         # Update path of opened file
         main = IDE.get_service('main_container')
         if main and main.is_open(pathForFile):
             widget = main.get_widget_for_path(pathForFile)
             if widget:
                 widget.ID = path
     except file_manager.NinjaFileExistsException as ex:
         QMessageBox.information(
             self, self.tr("File Already Exists"),
             (self.tr("Invalid Path: 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)
Example #23
0
    def _replace_results(self):
        """Replace the search with the proper text in all the files."""
        result = QMessageBox.question(self,
            translations.TR_REPLACE_FILES_CONTENTS,
            translations.TR_ARE_YOU_SURE_WANT_TO_REPLACE,
            buttons=QMessageBox.Yes | QMessageBox.No)
        if result == QMessageBox.Yes:
            for index in range(self._result_widget.topLevelItemCount()):
                parent = self._result_widget.topLevelItem(index)
                root_dir_name = parent.dir_name_root
                file_name = parent.text(0)
                file_path = file_manager.create_path(root_dir_name, file_name)
                try:
                    content = file_manager.read_file_content(file_path)
                    pattern = self._find_widget.pattern_line_edit.text()
                    flags = 0
                    if not self._find_widget.case_checkbox.isChecked():
                        flags |= re.IGNORECASE
                    if self._find_widget.type_checkbox.isChecked():
                        pattern = r'\b%s\b' % pattern

                    new_content = re.sub(pattern,
                        self._find_widget.replace_line.text(),
                        content, flags=flags)
                    file_manager.store_file_content(file_path,
                        new_content, False)
                except:
                    print(('File: {} content, could not be replaced'.format(
                           file_path)))
Example #24
0
 def delete_theme(self):
     if self.list_skins.currentRow() != 0:
         file_name = ("%s.qss" % self.list_skins.currentItem().text())
         qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD,
                                             file_name)
         file_manager.delete_file(qss_file)
         self._refresh_list()
 def _rename_file(self):
     path = self.model().filePath(self.currentIndex())
     name = file_manager.get_basename(path)
     new_name, ok = QInputDialog.getText(
         self, translations.TR_RENAME_FILE,
         translations.TR_ENTER_NEW_FILENAME,
         text=name)
     if ok and new_name.strip():
         filename = file_manager.create_path(
             file_manager.get_folder(path), new_name)
         if path == filename:
             return
         ninjaide = IDE.get_service("ide")
         print(ninjaide.filesystem.get_files())
         current_nfile = ninjaide.get_or_create_nfile(path)
         editable = ninjaide.get_editable(nfile=current_nfile)
         current_nfile.move(filename)
         if editable is not None:
             main_container = IDE.get_service("main_container")
             main_container.combo_area.bar.update_item_text(
                 editable, new_name)
             tree = ninjaide.filesystem.get_files()
             # FIXME: this is bad
             tree[filename] = tree.pop(path)
         print(ninjaide.filesystem.get_files())
 def _add_file_to_project(self, path):
     """Add the file for 'path' in the project the user choose here."""
     if self._active_project:
         pathProject = [self._active_project.project]
         addToProject = add_to_project.AddToProject(pathProject, self)
         addToProject.exec_()
         if not addToProject.pathSelected:
             return
         main_container = IDE.get_service('main_container')
         if not main_container:
             return
         editorWidget = main_container.get_current_editor()
         if not editorWidget.file_path:
             name = QInputDialog.getText(None,
                                         self.tr("Add File To Project"),
                                         self.tr("File Name:"))[0]
             if not name:
                 QMessageBox.information(
                     self, self.tr("Invalid Name"),
                     self.tr("The file name is empty, please enter a name"))
                 return
         else:
             name = file_manager.get_basename(editorWidget.file_path)
         new_path = file_manager.create_path(addToProject.pathSelected,
                                             name)
         ide_srv = IDE.get_service("ide")
         old_file, ide_srv.get_or_create_nfile(path)
         new_file = old_file.save(editorWidget.get_text(), path)
         #FIXME: Make this file replace the original in the open tab
     else:
         pass
    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 execute_project(self):
        """Execute the project marked as Main Project."""

        projects_explorer = IDE.get_service("projects_explorer")
        if projects_explorer is None:
            return
        nproject = projects_explorer.current_project
        if nproject:
            main_file = nproject.main_file
            if not main_file:
                # Open project properties to specify the main file
                projects_explorer.current_tree.open_project_properties()
            else:
                # Save project files
                projects_explorer.save_project()
                # Emit a signal for plugin!
                self.projectExecuted.emit(nproject.path)

                main_file = file_manager.create_path(nproject.path,
                                                     nproject.main_file)
                self.start_process(filename=main_file,
                                   python_exec=nproject.python_exec,
                                   pre_exec_script=nproject.pre_exec_script,
                                   post_exec_script=nproject.post_exec_script,
                                   program_params=nproject.program_params)
 def _move_file(self):
     path = self.model().filePath(self.currentIndex())
     global projectsColumn
     pathProjects = [p.path for p in projectsColumn.projects]
     addToProject = add_to_project.AddToProject(pathProjects, self)
     addToProject.setWindowTitle(self.tr("Copy File to"))
     addToProject.exec_()
     if not addToProject.pathSelected:
         return
     name = file_manager.get_basename(path)
     path = file_manager.create_path(addToProject.pathSelected, name)
     try:
         content = file_manager.read_file_content(path)
         path = file_manager.store_file_content(path, content, newFile=True)
         file_manager.delete_file(path)
         # Update path of opened file
         main = IDE.get_service('main_container')
         if main and main.is_open(path):
             widget = main.get_widget_for_path(path)
             if widget:
                 widget.ID = path
     except file_manager.NinjaFileExistsException as ex:
             QMessageBox.information(self, self.tr("File Already Exists"),
                 (self.tr("Invalid Path: the file '%s' already exists.") %
                     ex.filename))
Example #30
0
    def _replace_results(self):
        result = QMessageBox.question(self, self.tr("Replace Files Contents"),
            self.tr("Are you sure you want to replace the content in "
                    "this files?\n(The change is not reversible)"),
            buttons=QMessageBox.Yes | QMessageBox.No)
        if result == QMessageBox.Yes:
            for index in range(self._result_widget.topLevelItemCount()):
                parent = self._result_widget.topLevelItem(index)
                root_dir_name = parent.dir_name_root
                file_name = parent.text(0)
                file_path = file_manager.create_path(root_dir_name, file_name)
                try:
                    content = file_manager.read_file_content(file_path)
                    pattern = self._find_widget.pattern_line_edit.text()
                    flags = 0
                    if not self._find_widget.case_checkbox.isChecked():
                        flags |= re.IGNORECASE
                    if self._find_widget.type_checkbox.isChecked():
                        pattern = r'\b%s\b' % pattern

                    new_content = re.sub(pattern,
                        self._find_widget.replace_line.text(),
                        content, flags=flags)
                    file_manager.store_file_content(file_path,
                        new_content, False)
                except:
                    print('File: %s content, could not be replaced' %
                          file_path)
    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 preview_theme(self):
     if self.list_skins.currentRow() == 0:
         qss_file = resources.NINJA_THEME
     else:
         file_name = ("%s.qss" % self.list_skins.currentItem().text())
         qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD,
                                             file_name)
     with open(qss_file) as f:
         qss = f.read()
     QApplication.instance().setStyleSheet(qss)
Example #34
0
 def preview_theme(self):
     if self.list_skins.currentRow() == 0:
         qss_file = resources.NINJA_THEME
     else:
         file_name = ("%s.qss" % self.list_skins.currentItem().text())
         qss_file = file_manager.create_path(resources.NINJA_THEME_DOWNLOAD,
                                             file_name)
     with open(qss_file) as f:
         qss = f.read()
     QApplication.instance().setStyleSheet(qss)
Example #35
0
 def _go_to(self, item, val):
     if item.text(1):
         parent = item.parent()
         file_name = parent.text(0)
         lineno = item.text(1)
         root_dir_name = parent.dir_name_root
         file_path = file_manager.create_path(root_dir_name, file_name)
         #open the file and jump_to_line
         self._main_container.open_file(file_path)
         self._main_container.editor_jump_to_line(lineno=int(lineno) - 1)
Example #36
0
 def _go_to(self, item, val):
     if item.text(1):
         parent = item.parent()
         file_name = parent.text(0)
         lineno = item.text(1)
         root_dir_name = parent.dir_name_root
         file_path = file_manager.create_path(root_dir_name, file_name)
         #open the file and jump_to_line
         self._main_container.open_file(file_path)
         self._main_container.editor_jump_to_line(lineno=int(lineno) - 1)
Example #37
0
 def _go_to(self, item, val):
     """Open the proper file in the proper line from the results."""
     if item.text(1):
         parent = item.parent()
         file_name = parent.text(0)
         lineno = item.text(1)
         root_dir_name = parent.dir_name_root
         file_path = file_manager.create_path(root_dir_name, file_name)
         #open the file and jump_to_line
         self._main_container.open_file(file_path, line=int(lineno) - 1)
         self._main_container.get_current_editor().setFocus()
 def _go_to(self, item, val):
     """Open the proper file in the proper line from the results."""
     if item.text(1):
         parent = item.parent()
         file_name = parent.text(0)
         lineno = item.text(1)
         root_dir_name = parent.dir_name_root
         file_path = file_manager.create_path(root_dir_name, file_name)
         #open the file and jump_to_line
         self._main_container.open_file(file_path, line=int(lineno) - 1)
         self._main_container.get_current_editor().setFocus()
Example #39
0
 def _go_to(self, item, val):
     """Open the proper file in the proper line from the results."""
     if item.text(1):
         parent = item.parent()
         file_name = parent.text(0)
         lineno = item.text(1)
         root_dir_name = parent.dir_name_root
         file_path = file_manager.create_path(root_dir_name, file_name)
         #open the file and jump_to_line
         self._main_container.open_file(file_path,
                                        cursorPosition=int(lineno) - 1,
                                        positionIsLineNumber=True)
Example #40
0
 def _go_to(self, item, val):
     """Open the proper file in the proper line from the results."""
     if item.text(1):
         parent = item.parent()
         file_name = parent.text(0)
         lineno = item.text(1)
         root_dir_name = parent.dir_name_root
         file_path = file_manager.create_path(root_dir_name, file_name)
         #open the file and jump_to_line
         self._main_container.open_file(file_path,
             cursorPosition=int(lineno) - 1,
             positionIsLineNumber=True)
 def _delete_file(self):
     path = self.model().filePath(self.currentIndex())
     val = QMessageBox.question(self, self.tr("Delete File"),
             self.tr("Do you want to delete the following file: ")
             + path,
             QMessageBox.Yes, QMessageBox.No)
     if val == QMessageBox.Yes:
         path = file_manager.create_path(path)
         file_manager.delete_file(path)
         main_container = IDE.get_service('main_container')
         if main_container and main_container.is_open(path):
             main_container.close_deleted_file(path)
Example #42
0
 def _delete_file(self):
     item = self.currentItem()
     val = QMessageBox.question(self, self.tr("Delete File"),
             self.tr("Do you want to delete the following file: ")
             + os.path.join(item.path, item.text(0)),
             QMessageBox.Yes, QMessageBox.No)
     if val == QMessageBox.Yes:
         path = file_manager.create_path(item.path, item.text(0))
         file_manager.delete_file(item.path, item.text(0))
         index = item.parent().indexOfChild(item)
         item.parent().takeChild(index)
         main_container = IDE.get_service('main_container')
         if main_container and main_container.is_open(path):
             main_container.close_deleted_file(path)
 def _delete_file(self):
     item = self.currentItem()
     val = QMessageBox.question(
         self, self.tr("Delete File"),
         self.tr("Do you want to delete the following file: ") +
         os.path.join(item.path, item.text(0)), QMessageBox.Yes,
         QMessageBox.No)
     if val == QMessageBox.Yes:
         path = file_manager.create_path(item.path, item.text(0))
         file_manager.delete_file(item.path, item.text(0))
         index = item.parent().indexOfChild(item)
         item.parent().takeChild(index)
         main_container = IDE.get_service('main_container')
         if main_container and main_container.is_open(path):
             main_container.close_deleted_file(path)
 def _move_file(self):
     path = self.model().filePath(self.currentIndex())
     global projectsColumn
     pathProjects = [p.project for p in projectsColumn.projects]
     addToProject = add_to_project.AddToProject(pathProjects, self)
     addToProject.setWindowTitle(translations.TR_COPY_FILE_TO)
     addToProject.exec_()
     if not addToProject.pathSelected:
         return
     name = file_manager.get_basename(path)
     new_path = file_manager.create_path(addToProject.pathSelected, name)
     ide_srv = IDE.get_service("ide")
     current_nfile = ide_srv.get_or_create_nfile(path)
     # FIXME: Catch willOverWrite and willMove signals
     current_nfile.move(new_path)
Example #45
0
 def _move_file(self):
     path = self.model().filePath(self.currentIndex())
     global projectsColumn
     pathProjects = [p.project for p in projectsColumn.projects]
     addToProject = add_to_project.AddToProject(pathProjects, self)
     addToProject.setWindowTitle(translations.TR_COPY_FILE_TO)
     addToProject.exec_()
     if not addToProject.pathSelected:
         return
     name = file_manager.get_basename(path)
     new_path = file_manager.create_path(addToProject.pathSelected, name)
     ide_srv = IDE.get_service("ide")
     current_nfile = ide_srv.get_or_create_nfile(path)
     #FIXME: Catch willOverWrite and willMove signals
     current_nfile.move(new_path)
Example #46
0
 def _delete_file(self, path=''):
     if not path:
         path = self.model().filePath(self.currentIndex())
     val = QMessageBox.question(self, translations.TR_DELETE_FILE,
                                translations.TR_DELETE_FOLLOWING_FILE + path,
                                QMessageBox.Yes, QMessageBox.No)
     if val == QMessageBox.Yes:
         path = file_manager.create_path(path)
         main_container = ide_srv = IDE.get_service('main_container')
         if main_container and main_container.is_open(path):
             main_container.close_deleted_file(path)
         #FIXME: Manage the deletion signal instead of main container
         #fiddling here
         ide_srv = IDE.getInstance()
         current_nfile = ide_srv.get_or_create_nfile(path)
         current_nfile.delete()
Example #47
0
 def _delete_file(self, path=''):
     if not path:
         path = self.model().filePath(self.currentIndex())
     val = QMessageBox.question(self, translations.TR_DELETE_FILE,
                                translations.TR_DELETE_FOLLOWING_FILE + path,
                                QMessageBox.Yes, QMessageBox.No)
     if val == QMessageBox.Yes:
         path = file_manager.create_path(path)
         main_container = ide_srv = IDE.get_service('main_container')
         if main_container and main_container.is_open(path):
             main_container.close_deleted_file(path)
         #FIXME: Manage the deletion signal instead of main container
         #fiddling here
         ide_srv = IDE.get_service('ide')
         current_nfile = ide_srv.get_or_create_nfile(path)
         current_nfile.delete()
 def _delete_file(self, path=''):
     if not path:
         path = self.model().filePath(self.currentIndex())
     val = QMessageBox.question(
         self, self.tr("Delete File"),
         self.tr("Do you want to delete the following file: ") + path,
         QMessageBox.Yes, QMessageBox.No)
     if val == QMessageBox.Yes:
         path = file_manager.create_path(path)
         main_container = ide_srv = IDE.get_service('main_container')
         if main_container and main_container.is_open(path):
             main_container.close_deleted_file(path)
         #FIXME: Manage the deletion signal instead of main container
         #fiddling here
         ide_srv = IDE.get_service('ide')
         current_nfile = ide_srv.get_or_create_nfile(path)
         current_nfile.delete()
 def _move_file(self):
     path = self.model().filePath(self.currentIndex())
     global projectsColumn
     path_projects = [p.project for p in projectsColumn.projects]
     add_to_project_dialog = add_to_project.AddToProject(path_projects)
     add_to_project_dialog.setWindowTitle(translations.TR_MOVE_FILE)
     add_to_project_dialog.exec_()
     if not add_to_project_dialog.path_selected:
         return
     name = file_manager.get_basename(path)
     new_path = file_manager.create_path(
         add_to_project_dialog.path_selected, name)
     ninjaide = IDE.get_service("ide")
     current_nfile = ninjaide.get_or_create_nfile(path)
     current_nfile.close()
     # FIXME: Catch willOverWrite and willMove signals
     current_nfile.move(new_path)
 def _move_file(self):
     path = self.model().filePath(self.currentIndex())
     global projectsColumn
     path_projects = [p.project for p in projectsColumn.projects]
     add_to_project_dialog = add_to_project.AddToProject(path_projects)
     add_to_project_dialog.setWindowTitle(translations.TR_MOVE_FILE)
     add_to_project_dialog.exec_()
     if not add_to_project_dialog.path_selected:
         return
     name = file_manager.get_basename(path)
     new_path = file_manager.create_path(
         add_to_project_dialog.path_selected, name)
     ninjaide = IDE.get_service("ide")
     current_nfile = ninjaide.get_or_create_nfile(path)
     current_nfile.close()
     # FIXME: Catch willOverWrite and willMove signals
     current_nfile.move(new_path)
    def _refresh_project(self, item=None):
        if item is None:
            item = self.currentItem()
        parentItem = self._get_project_root(item)
        if parentItem is None:
            return
        if item.parent() is None:
            path = item.path
        else:
            path = file_manager.create_path(item.path, item.text(0))

        thread = ui_tools.ThreadProjectExplore()
        self._thread_execution[path] = thread
        self.connect(thread, SIGNAL("folderDataRefreshed(PyQt_PyObject)"),
            self._callback_refresh_project)
        self.connect(thread, SIGNAL("finished()"), self._clean_threads)
        thread.refresh_project(path, item, parentItem.extensions)
 def _delete_file(self, path=''):
     if not path:
         path = self.model().filePath(self.currentIndex())
     val = QMessageBox.question(self, self.tr("Delete File"),
             self.tr("Do you want to delete the following file: ")
             + path,
             QMessageBox.Yes, QMessageBox.No)
     if val == QMessageBox.Yes:
         path = file_manager.create_path(path)
         main_container = ide_srv = IDE.get_service('main_container')
         if main_container and main_container.is_open(path):
             main_container.close_deleted_file(path)
         #FIXME: Manage the deletion signal instead of main container
         #fiddling here
         ide_srv = IDE.get_service('ide')
         current_nfile = ide_srv.get_or_create_nfile(path)
         current_nfile.delete()
    def _refresh_project(self, item=None):
        if item is None:
            item = self.currentItem()
        parentItem = self._get_project_root(item)
        if parentItem is None:
            return
        if item.parent() is None:
            path = item.path
        else:
            path = file_manager.create_path(item.path, item.text(0))

        thread = ui_tools.ThreadProjectExplore()
        self._thread_execution[path] = thread
        self.connect(thread, SIGNAL("folderDataRefreshed(PyQt_PyObject)"),
                     self._callback_refresh_project)
        self.connect(thread, SIGNAL("finished()"), self._clean_threads)
        thread.refresh_project(path, item, parentItem.extensions)
Example #54
0
 def _add_file_to_project(self, path):
     """Add the file for 'path' in the project the user choose here."""
     pathProject = [self.get_actual_project()]
     addToProject = ui_tools.AddToProject(pathProject, self.ide)
     addToProject.exec_()
     if not addToProject.pathSelected:
         return
     main_container = IDE.get_service('main_container')
     if not main_container:
         return
     editorWidget = main_container.get_actual_editor()
     if not editorWidget.ID:
         name = QInputDialog.getText(None, self.tr("Add File To Project"),
                                     self.tr("File Name:"))[0]
         if not name:
             QMessageBox.information(
                 self, self.tr("Invalid Name"),
                 self.tr("The file name is empty, please enter a name"))
             return
     else:
         name = file_manager.get_basename(editorWidget.ID)
     path = file_manager.create_path(addToProject.pathSelected, name)
     try:
         path = file_manager.store_file_content(path,
                                                editorWidget.get_text(),
                                                newFile=True)
         main_container._file_watcher.allow_kill = False
         if path != editorWidget.ID:
             main_container.remove_standalone_watcher(editorWidget.ID)
         editorWidget.ID = path
         main_container.add_standalone_watcher(path)
         main_container._file_watcher.allow_kill = True
         self.add_existing_file(path)
         self.emit(SIGNAL("changeWindowTitle(QString)"), path)
         name = file_manager.get_basename(path)
         main_container.actualTab.setTabText(
             main_container.actualTab.currentIndex(), name)
         editorWidget._file_saved()
     except file_manager.NinjaFileExistsException as ex:
         QMessageBox.information(
             self, self.tr("File Already Exists"),
             (self.tr("Invalid Path: the file '%s' already exists.") %
              ex.filename))
Example #55
0
 def _add_file_to_project(self, path):
     """Add the file for 'path' in the project the user choose here."""
     pathProject = [self.get_actual_project()]
     addToProject = ui_tools.AddToProject(pathProject, self.ide)
     addToProject.exec_()
     if not addToProject.pathSelected:
         return
     main_container = IDE.get_service('main_container')
     if not main_container:
         return
     editorWidget = main_container.get_actual_editor()
     if not editorWidget.ID:
         name = QInputDialog.getText(None,
             self.tr("Add File To Project"), self.tr("File Name:"))[0]
         if not name:
             QMessageBox.information(self, self.tr("Invalid Name"),
                 self.tr("The file name is empty, please enter a name"))
             return
     else:
         name = file_manager.get_basename(editorWidget.ID)
     path = file_manager.create_path(addToProject.pathSelected, name)
     try:
         path = file_manager.store_file_content(
             path, editorWidget.get_text(), newFile=True)
         main_container._file_watcher.allow_kill = False
         if path != editorWidget.ID:
             main_container.remove_standalone_watcher(
                 editorWidget.ID)
         editorWidget.ID = path
         main_container.add_standalone_watcher(path)
         main_container._file_watcher.allow_kill = True
         self.add_existing_file(path)
         self.emit(SIGNAL("changeWindowTitle(QString)"), path)
         name = file_manager.get_basename(path)
         main_container.actualTab.setTabText(
             main_container.actualTab.currentIndex(), name)
         editorWidget._file_saved()
     except file_manager.NinjaFileExistsException as ex:
         QMessageBox.information(self, self.tr("File Already Exists"),
             (self.tr("Invalid Path: the file '%s' already exists.") %
                 ex.filename))
 def _copy_file(self):
     path = self.model().filePath(self.currentIndex())
     name = file_manager.get_basename(path)
     global projectsColumn
     pathProjects = [p.project for p in projectsColumn.projects]
     addToProject = add_to_project.AddToProject(pathProjects, self)
     addToProject.setWindowTitle(self.tr("Copy File to"))
     addToProject.exec_()
     if not addToProject.pathSelected:
         return
     name = QInputDialog.getText(self, self.tr("Copy File"),
         self.tr("File Name:"), text=name)[0]
     if not name:
         QMessageBox.information(self, self.tr("Invalid Name"),
             self.tr("The file name is empty, please enter a name"))
         return
     new_path = file_manager.create_path(addToProject.pathSelected, name)
     ide_srv = IDE.get_service("ide")
     current_nfile = ide_srv.get_or_create_nfile(path)
     #FIXME: Catch willOverWrite and willCopyTo signals
     current_nfile.copy(new_path)
Example #57
0
    def execute_project(self):
        """Execute the project marked as Main Project."""
        projects_explorer = IDE.get_service('projects_explorer')
        if projects_explorer is None:
            return
        nproject = projects_explorer.current_project
        if nproject:
            main_file = nproject.main_file
            if not main_file and projects_explorer.current_tree:
                projects_explorer.current_tree.open_project_properties()
            elif main_file:
                projects_explorer.save_project()
                #emit a signal for plugin!
                self.emit(SIGNAL("projectExecuted(QString)"), nproject.path)

                main_file = file_manager.create_path(nproject.path,
                    nproject.main_file)
                self._run_application(main_file,
                    pythonExec=nproject.python_exec_command,
                    PYTHONPATH=nproject.python_path,
                    programParams=nproject.program_params,
                    preExec=nproject.pre_exec_script,
                    postExec=nproject.post_exec_script)
Example #58
0
    def execute_project(self):
        """Execute the project marked as Main Project."""
        ide = IDE.get_service('ide')
        nproject = ide.get_current_project()
        main_file = nproject.main_file
        explorer_container = IDE.get_service('explorer_container')
        if not explorer_container:
            return
        if not main_file and explorer_container._treeProjects and \
          explorer_container._treeProjects._actualProject:
            explorer_container._treeProjects.open_project_properties()
        elif main_file:
            self.save_project()
            #emit a signal for plugin!
            self.emit(SIGNAL("projectExecuted(QString)"), nproject.path)

            main_file = file_manager.create_path(nproject.path,
                                                 nproject.main_file)
            self.run_application(main_file,
                                 pythonPath=nproject.python_exec_command,
                                 PYTHONPATH=nproject.python_path,
                                 programParams=nproject.program_params,
                                 preExec=nproject.pre_exec_script,
                                 postExec=nproject.post_exec_script)
 def _copy_file(self):
     path = self.model().filePath(self.currentIndex())
     name = file_manager.get_basename(path)
     global projectsColumn
     pathProjects = [p.project for p in projectsColumn.projects]
     addToProject = add_to_project.AddToProject(pathProjects, self)
     addToProject.setWindowTitle(self.tr("Copy File to"))
     addToProject.exec_()
     if not addToProject.pathSelected:
         return
     name = QInputDialog.getText(self,
                                 self.tr("Copy File"),
                                 self.tr("File Name:"),
                                 text=name)[0]
     if not name:
         QMessageBox.information(
             self, self.tr("Invalid Name"),
             self.tr("The file name is empty, please enter a name"))
         return
     new_path = file_manager.create_path(addToProject.pathSelected, name)
     ide_srv = IDE.get_service("ide")
     current_nfile = ide_srv.get_or_create_nfile(path)
     #FIXME: Catch willOverWrite and willCopyTo signals
     current_nfile.copy(new_path)