ExtensionProtobuf/ProjectProtocolsBrowser.py

Sat, 23 Dec 2023 19:40:22 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 23 Dec 2023 19:40:22 +0100
changeset 41
afe67fcf2a19
parent 40
c187d961ee3a
child 42
24ed3e1583dc
permissions
-rw-r--r--

Converted some source code documentation to the new style.

1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
40
c187d961ee3a Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 34
diff changeset
3 # Copyright (c) 2017 - 2024 Detlev Offenbach <detlev@die-offenbachs.de>
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the a class used to display the protocols (protobuf) part
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 of the project.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import contextlib
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import functools
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 import glob
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 import os
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 from PyQt6.QtCore import QProcess, QThread, pyqtSignal
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from PyQt6.QtWidgets import QApplication, QDialog, QMenu
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
12
8ddcd9d47bdf Changed some import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
19 from eric7 import Preferences
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 from eric7.EricGui import EricPixmapCache
27
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
21 from eric7.EricWidgets import EricMessageBox, EricPathPickerDialog
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 from eric7.EricWidgets.EricApplication import ericApp
27
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
23 from eric7.EricWidgets.EricPathPickerDialog import EricPathPickerModes
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 from eric7.EricWidgets.EricProgressDialog import EricProgressDialog
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 from eric7.Project.FileCategoryRepositoryItem import FileCategoryRepositoryItem
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 from eric7.Project.ProjectBaseBrowser import ProjectBaseBrowser
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 from eric7.Project.ProjectBrowserModel import (
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 ProjectBrowserDirectoryItem,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 ProjectBrowserFileItem,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 ProjectBrowserSimpleDirectoryItem,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 from eric7.Project.ProjectBrowserRepositoryItem import ProjectBrowserRepositoryItem
12
8ddcd9d47bdf Changed some import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
33 from eric7.SystemUtilities import FileSystemUtilities, OSUtilities, PythonUtilities
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 from eric7.UI.BrowserModel import (
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 BrowserClassAttributeItem,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 BrowserClassItem,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 BrowserFileItem,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 BrowserMethodItem,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 from eric7.UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 from eric7.UI.NotificationWidget import NotificationTypes
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 class ProjectProtocolsBrowser(ProjectBaseBrowser):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 A class used to display the protocols (protobuf) part of the project.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 @signal appendStdout(str) emitted after something was received from
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 a QProcess on stdout
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 @signal appendStderr(str) emitted after something was received from
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 a QProcess on stderr
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 @signal showMenu(str, QMenu) emitted when a menu is about to be shown.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 The name of the menu and a reference to the menu are given.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 appendStdout = pyqtSignal(str)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 appendStderr = pyqtSignal(str)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 showMenu = pyqtSignal(str, QMenu)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 FileFilter = "proto"
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 def __init__(self, plugin, parent=None):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 Constructor
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 @param plugin reference to the plugin object
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 @type ProtobufExtensionPlugin
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 @param parent parent widget of this browser
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 @type QWidget
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 project = ericApp().getObject("Project")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 projectBrowser = ericApp().getObject("ProjectBrowser")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 ProjectBaseBrowser.__init__(self, project, self.FileFilter, parent)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.selectedItemsFilter = [
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 ProjectBrowserFileItem,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 ProjectBrowserSimpleDirectoryItem,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 ]
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.setWindowTitle(self.tr("Protocols (protobuf)"))
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 self.setWhatsThis(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 self.tr(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 """<b>Project Protocols Browser</b>"""
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 """<p>This allows to easily see all protocols (protobuf files)"""
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 """ contained in the current project. Several actions can be"""
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 """ executed via the context menu.</p>"""
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self.__plugin = plugin
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 # Add the file category handled by the browser.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 project.addFileCategory(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 "PROTOCOLS",
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 FileCategoryRepositoryItem(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 fileCategoryFilterTemplate=self.tr("Protobuf Files ({0})"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 fileCategoryUserString=self.tr("Protobuf Files"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 fileCategoryTyeString=self.tr("Protobuf Files"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 fileCategoryExtensions=["*.proto"],
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 ),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 # Add the project browser type to the browser type repository.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 projectBrowser.addTypedProjectBrowser(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 "protocols",
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 ProjectBrowserRepositoryItem(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 projectBrowser=self,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 projectBrowserUserString=self.tr("Protocols (protobuf) Browser"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 priority=50,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 fileCategory="PROTOCOLS",
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 fileFilter=self.FileFilter,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 getIcon=self.getIcon,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 ),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 # Connect signals of Project.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 project.prepareRepopulateItem.connect(self._prepareRepopulateItem)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 project.completeRepopulateItem.connect(self._completeRepopulateItem)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 project.projectClosed.connect(self._projectClosed)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 project.projectOpened.connect(self._projectOpened)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 project.newProject.connect(self._newProject)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 project.reinitVCS.connect(self._initMenusAndVcs)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 project.projectPropertiesChanged.connect(self._initMenusAndVcs)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 # Connect signals of ProjectBrowser.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 projectBrowser.preferencesChanged.connect(self.handlePreferencesChanged)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 # Connect some of our own signals.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 self.appendStderr.connect(projectBrowser.appendStderr)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 self.appendStdout.connect(projectBrowser.appendStdout)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 self.closeSourceWindow.connect(projectBrowser.closeSourceWindow)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 self.sourceFile[str].connect(projectBrowser.sourceFile[str])
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 self.sourceFile[str, int].connect(projectBrowser.sourceFile[str, int])
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 def deactivate(self):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 Public method to deactivate the browser.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 project = ericApp().getObject("Project")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 projectBrowser = ericApp().getObject("ProjectBrowser")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 # Disconnect some of our own signals.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 self.appendStderr.disconnect(projectBrowser.appendStderr)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 self.appendStdout.disconnect(projectBrowser.appendStdout)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 self.closeSourceWindow.disconnect(projectBrowser.closeSourceWindow)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 self.sourceFile[str].disconnect(projectBrowser.sourceFile[str])
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 self.sourceFile[str, int].disconnect(projectBrowser.sourceFile[str, int])
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 # Disconnect signals of ProjectBrowser.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 projectBrowser.preferencesChanged.disconnect(self.handlePreferencesChanged)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 # Disconnect signals of Project.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 project.prepareRepopulateItem.disconnect(self._prepareRepopulateItem)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 project.completeRepopulateItem.disconnect(self._completeRepopulateItem)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 project.projectClosed.disconnect(self._projectClosed)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 project.projectOpened.disconnect(self._projectOpened)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 project.newProject.disconnect(self._newProject)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 project.reinitVCS.disconnect(self._initMenusAndVcs)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 project.projectPropertiesChanged.disconnect(self._initMenusAndVcs)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 # Remove the project browser type from the browser type repository.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 projectBrowser.removeTypedProjectBrowser("protocols")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 # Remove the file category handled by the browser.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 project.removeFileCategory("PROTOCOLS")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 def getIcon(self):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 Public method to get an icon for the project browser.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 @return icon for the browser
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 @rtype QIcon
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 return EricPixmapCache.getIcon(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 os.path.join(os.path.dirname(__file__), "icons", "protobuf")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 def _createPopupMenus(self):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 Protected overloaded method to generate the popup menu.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 self.menuActions = []
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 self.multiMenuActions = []
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 self.dirMenuActions = []
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 self.dirMultiMenuActions = []
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 self.sourceMenu = QMenu(self)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 self.sourceMenu.addAction(self.tr("Compile protocol"), self.__compileProtocol)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 self.sourceMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 self.tr("Compile all protocols"), self.__compileAllProtocols
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 self.sourceMenu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 self.sourceMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 self.tr("Compile protocol as gRPC"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 functools.partial(self.__compileProtocol, grpc=True),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 self.sourceMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 self.tr("Compile all protocols as gRPC"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 functools.partial(self.__compileAllProtocols, grpc=True),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 self.sourceMenu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 self.sourceMenu.addAction(self.tr("Open"), self._openItem)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 self.sourceMenu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 act = self.sourceMenu.addAction(self.tr("Rename file"), self._renameFile)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 self.menuActions.append(act)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 act = self.sourceMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 self.tr("Remove from project"), self._removeFile
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 self.menuActions.append(act)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 act = self.sourceMenu.addAction(self.tr("Delete"), self.__deleteFile)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 self.menuActions.append(act)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 self.sourceMenu.addSeparator()
27
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
215 self.sourceMenu.addAction(
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
216 self.tr("New protocol file..."), self.__addNewProtocolFile
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
217 )
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
218 self.sourceMenu.addSeparator()
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 self.sourceMenu.addAction(self.tr("Add protocols..."), self.__addProtocolFiles)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 self.sourceMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 self.tr("Add protocols directory..."), self.__addProtocolsDirectory
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 self.sourceMenu.addSeparator()
34
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
224 with contextlib.suppress(AttributeError):
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
225 # eric7 > 23.12
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
226 self.sourceMenu.addAction(
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
227 self.tr("Show in File Manager"), self._showInFileManager
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
228 )
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 self.sourceMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 self.tr("Copy Path to Clipboard"), self._copyToClipboard
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 self.sourceMenu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 self.sourceMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 self.tr("Expand all directories"), self._expandAllDirs
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 self.sourceMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 self.tr("Collapse all directories"), self._collapseAllDirs
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 )
8
24fdd6e43cd7 Added a `Collapse all files` entry to the context menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
239 self.sourceMenu.addAction(self.tr("Collapse all files"), self._collapseAllFiles)
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 self.sourceMenu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 self.sourceMenu.addAction(self.tr("Configure..."), self._configure)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 self.sourceMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 self.tr("Configure Protobuf..."), self.__configureProtobuf
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 self.menu = QMenu(self)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 self.menu.addAction(self.tr("Compile protocol"), self.__compileProtocol)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 self.menu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 self.tr("Compile all protocols"), self.__compileAllProtocols
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 self.menu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 self.menu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 self.tr("Compile protocol as gRPC"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 functools.partial(self.__compileProtocol, grpc=True),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 self.menu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 self.tr("Compile all protocols as gRPC"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 functools.partial(self.__compileAllProtocols, grpc=True),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 self.menu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 self.menu.addAction(self.tr("Open"), self._openItem)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 self.menu.addSeparator()
27
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
263 self.menu.addAction(self.tr("New protocol file..."), self.__addNewProtocolFile)
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
264 self.menu.addSeparator()
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 self.menu.addAction(self.tr("Add protocols..."), self.__addProtocolFiles)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 self.menu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 self.tr("Add protocols directory..."), self.__addProtocolsDirectory
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 self.menu.addSeparator()
34
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
270 with contextlib.suppress(AttributeError):
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
271 # eric7 > 23.12
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
272 self.menu.addAction(
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
273 self.tr("Show in File Manager"), self._showInFileManager
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
274 )
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
275 self.menu.addSeparator()
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 self.menu.addAction(self.tr("Expand all directories"), self._expandAllDirs)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 self.menu.addAction(self.tr("Collapse all directories"), self._collapseAllDirs)
8
24fdd6e43cd7 Added a `Collapse all files` entry to the context menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
278 self.menu.addAction(self.tr("Collapse all files"), self._collapseAllFiles)
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 self.menu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 self.menu.addAction(self.tr("Configure..."), self._configure)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 self.menu.addAction(self.tr("Configure Protobuf..."), self.__configureProtobuf)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 self.backMenu = QMenu(self)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 self.backMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 self.tr("Compile all protocols"), self.__compileAllProtocols
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 self.backMenu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 self.backMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 self.tr("Compile all protocols as gRPC"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 functools.partial(self.__compileAllProtocols, grpc=True),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 self.backMenu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 self.backMenu.addAction(
27
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
294 self.tr("New protocol file..."), self.__addNewProtocolFile
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
295 )
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
296 self.backMenu.addSeparator()
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
297 self.backMenu.addAction(
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 self.tr("Add protocols..."), lambda: self.project.addFiles("PROTOCOLS")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 self.backMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 self.tr("Add protocols directory..."),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 lambda: self.project.addDirectory("PROTOCOLS"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 self.backMenu.addSeparator()
34
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
305 with contextlib.suppress(AttributeError):
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
306 # eric7 > 23.12
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
307 self.backMenu.addAction(
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
308 self.tr("Show in File Manager"), self._showProjectInFileManager
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
309 )
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
310 self.backMenu.addSeparator()
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 self.backMenu.addAction(self.tr("Expand all directories"), self._expandAllDirs)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 self.backMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 self.tr("Collapse all directories"), self._collapseAllDirs
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 )
8
24fdd6e43cd7 Added a `Collapse all files` entry to the context menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
315 self.backMenu.addAction(self.tr("Collapse all files"), self._collapseAllFiles)
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 self.backMenu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 self.backMenu.addAction(self.tr("Configure..."), self._configure)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 self.backMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 self.tr("Configure Protobuf..."), self.__configureProtobuf
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 self.backMenu.setEnabled(False)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 # create the menu for multiple selected files
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 self.multiMenu = QMenu(self)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 self.multiMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 self.tr("Compile protocols"), self.__compileSelectedProtocols
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 self.multiMenu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 self.multiMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 self.tr("Compile protocols as gRPC"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 functools.partial(self.__compileSelectedProtocols, grpc=True),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 self.multiMenu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 self.multiMenu.addAction(self.tr("Open"), self._openItem)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 self.multiMenu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 act = self.multiMenu.addAction(self.tr("Remove from project"), self._removeFile)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 self.multiMenuActions.append(act)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 act = self.multiMenu.addAction(self.tr("Delete"), self.__deleteFile)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 self.multiMenuActions.append(act)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 self.multiMenu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 self.multiMenu.addAction(self.tr("Expand all directories"), self._expandAllDirs)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 self.multiMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 self.tr("Collapse all directories"), self._collapseAllDirs
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 )
8
24fdd6e43cd7 Added a `Collapse all files` entry to the context menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
345 self.multiMenu.addAction(self.tr("Collapse all files"), self._collapseAllFiles)
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 self.multiMenu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 self.multiMenu.addAction(self.tr("Configure..."), self._configure)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 self.multiMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 self.tr("Configure Protobuf..."), self.__configureProtobuf
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 self.dirMenu = QMenu(self)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 self.dirMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 self.tr("Compile all protocols"), self.__compileAllProtocols
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 self.dirMenu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 self.dirMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 self.tr("Compile all protocols as gRPC"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 functools.partial(self.__compileAllProtocols, grpc=True),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 act = self.dirMenu.addAction(self.tr("Remove from project"), self._removeFile)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 self.dirMenuActions.append(act)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 act = self.dirMenu.addAction(self.tr("Delete"), self._deleteDirectory)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 self.dirMenuActions.append(act)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 self.dirMenu.addSeparator()
27
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
366 self.dirMenu.addAction(
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
367 self.tr("New protocol file..."), self.__addNewProtocolFile
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
368 )
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
369 self.dirMenu.addSeparator()
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 self.dirMenu.addAction(self.tr("Add protocols..."), self.__addProtocolFiles)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 self.dirMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 self.tr("Add protocols directory..."), self.__addProtocolsDirectory
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 self.dirMenu.addSeparator()
34
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
375 with contextlib.suppress(AttributeError):
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
376 # eric7 > 23.12
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
377 self.dirMenu.addAction(
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
378 self.tr("Show in File Manager"), self._showInFileManager
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
379 )
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 self.dirMenu.addAction(self.tr("Copy Path to Clipboard"), self._copyToClipboard)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 self.dirMenu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 self.dirMenu.addAction(self.tr("Expand all directories"), self._expandAllDirs)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 self.dirMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 self.tr("Collapse all directories"), self._collapseAllDirs
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 )
8
24fdd6e43cd7 Added a `Collapse all files` entry to the context menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
386 self.dirMenu.addAction(self.tr("Collapse all files"), self._collapseAllFiles)
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 self.dirMenu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 self.dirMenu.addAction(self.tr("Configure..."), self._configure)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 self.dirMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 self.tr("Configure Protobuf..."), self.__configureProtobuf
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 self.dirMultiMenu = QMenu(self)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 self.dirMultiMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 self.tr("Compile all protocols"), self.__compileAllProtocols
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 self.dirMultiMenu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 self.dirMultiMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 self.tr("Compile all protocols as gRPC"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400 functools.partial(self.__compileAllProtocols, grpc=True),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 self.dirMultiMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 self.tr("Add protocols..."), lambda: self.project.addFiles("PROTOCOLS")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 self.dirMultiMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 self.tr("Add protocols directory..."),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 lambda: self.project.addDirectory("PROTOCOLS"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 self.dirMultiMenu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410 self.dirMultiMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 self.tr("Expand all directories"), self._expandAllDirs
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 self.dirMultiMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414 self.tr("Collapse all directories"), self._collapseAllDirs
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 )
8
24fdd6e43cd7 Added a `Collapse all files` entry to the context menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
416 self.dirMultiMenu.addAction(
24fdd6e43cd7 Added a `Collapse all files` entry to the context menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
417 self.tr("Collapse all files"), self._collapseAllFiles
24fdd6e43cd7 Added a `Collapse all files` entry to the context menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
418 )
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 self.dirMultiMenu.addSeparator()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 self.dirMultiMenu.addAction(self.tr("Configure..."), self._configure)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 self.dirMultiMenu.addAction(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 self.tr("Configure Protobuf..."), self.__configureProtobuf
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 self.sourceMenu.aboutToShow.connect(self.__showContextMenu)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 self.multiMenu.aboutToShow.connect(self.__showContextMenuMulti)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 self.dirMenu.aboutToShow.connect(self.__showContextMenuDir)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 self.dirMultiMenu.aboutToShow.connect(self.__showContextMenuDirMulti)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 self.backMenu.aboutToShow.connect(self.__showContextMenuBack)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
430 self.mainMenu = self.sourceMenu
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432 def _contextMenuRequested(self, coord):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434 Protected slot to show the context menu.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435
41
afe67fcf2a19 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 40
diff changeset
436 @param coord the position of the mouse pointer
afe67fcf2a19 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 40
diff changeset
437 @type QPoint
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 if not self.project.isOpen():
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440 return
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442 with contextlib.suppress(Exception): # secok
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 categories = self.getSelectedItemsCountCategorized(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 [
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 ProjectBrowserFileItem,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 BrowserClassItem,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 BrowserMethodItem,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 ProjectBrowserSimpleDirectoryItem,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 ]
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 cnt = categories["sum"]
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452 if cnt <= 1:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453 index = self.indexAt(coord)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 if index.isValid():
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 self._selectSingleItem(index)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 categories = self.getSelectedItemsCountCategorized(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457 [
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 ProjectBrowserFileItem,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 BrowserClassItem,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 BrowserMethodItem,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 ProjectBrowserSimpleDirectoryItem,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 ]
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464 cnt = categories["sum"]
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 bfcnt = categories[str(ProjectBrowserFileItem)]
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 cmcnt = (
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468 categories[str(BrowserClassItem)] + categories[str(BrowserMethodItem)]
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 sdcnt = categories[str(ProjectBrowserSimpleDirectoryItem)]
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 if cnt > 1 and cnt == bfcnt:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472 self.multiMenu.popup(self.mapToGlobal(coord))
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473 elif cnt > 1 and cnt == sdcnt:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 self.dirMultiMenu.popup(self.mapToGlobal(coord))
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475 else:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 index = self.indexAt(coord)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477 if cnt == 1 and index.isValid():
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478 if bfcnt == 1 or cmcnt == 1:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479 itm = self.model().item(index)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 if isinstance(itm, ProjectBrowserFileItem):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481 self.sourceMenu.popup(self.mapToGlobal(coord))
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 elif isinstance(itm, (BrowserClassItem, BrowserMethodItem)):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483 self.menu.popup(self.mapToGlobal(coord))
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
484 else:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
485 self.backMenu.popup(self.mapToGlobal(coord))
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
486 elif sdcnt == 1:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
487 self.dirMenu.popup(self.mapToGlobal(coord))
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
488 else:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489 self.backMenu.popup(self.mapToGlobal(coord))
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490 else:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 self.backMenu.popup(self.mapToGlobal(coord))
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
492
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
493 def __showContextMenu(self):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
494 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495 Private slot called by the menu aboutToShow signal.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 ProjectBaseBrowser._showContextMenu(self, self.menu)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 self.showMenu.emit("Main", self.menu)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501 def __showContextMenuMulti(self):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503 Private slot called by the multiMenu aboutToShow signal.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 ProjectBaseBrowser._showContextMenuMulti(self, self.multiMenu)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
506
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507 self.showMenu.emit("MainMulti", self.multiMenu)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509 def __showContextMenuDir(self):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
510 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511 Private slot called by the dirMenu aboutToShow signal.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
512 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
513 ProjectBaseBrowser._showContextMenuDir(self, self.dirMenu)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
514
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
515 self.showMenu.emit("MainDir", self.dirMenu)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
517 def __showContextMenuDirMulti(self):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
518 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
519 Private slot called by the dirMultiMenu aboutToShow signal.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
520 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
521 ProjectBaseBrowser._showContextMenuDirMulti(self, self.dirMultiMenu)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
522
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523 self.showMenu.emit("MainDirMulti", self.dirMultiMenu)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
524
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525 def __showContextMenuBack(self):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
526 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527 Private slot called by the backMenu aboutToShow signal.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
528 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529 ProjectBaseBrowser._showContextMenuBack(self, self.backMenu)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
531 self.showMenu.emit("MainBack", self.backMenu)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
532
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
533 def _openItem(self):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
535 Protected slot to handle the open popup menu entry.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
536 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
537 itmList = self.getSelectedItems(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
538 [
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539 BrowserFileItem,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
540 BrowserClassItem,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541 BrowserMethodItem,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 BrowserClassAttributeItem,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543 ]
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546 for itm in itmList:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
547 if isinstance(itm, BrowserFileItem):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 self.sourceFile[str].emit(itm.fileName())
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549 elif isinstance(itm, BrowserClassItem):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550 self.sourceFile[str, int].emit(itm.fileName(), itm.classObject().lineno)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551 elif isinstance(itm, BrowserMethodItem):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
552 self.sourceFile[str, int].emit(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553 itm.fileName(), itm.functionObject().lineno
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
555 elif isinstance(itm, BrowserClassAttributeItem):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
556 self.sourceFile[str, int].emit(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
557 itm.fileName(), itm.attributeObject().lineno
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
558 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
559
27
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
560 def __addNewProtocolFile(self):
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
561 """
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
562 Private method to add a new interface file to the project.
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
563 """
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
564 itm = self.model().item(self.currentIndex())
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
565 if isinstance(
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
566 itm, (ProjectBrowserFileItem, BrowserClassItem, BrowserMethodItem)
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
567 ):
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
568 dn = os.path.dirname(itm.fileName())
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
569 elif isinstance(
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
570 itm, (ProjectBrowserSimpleDirectoryItem, ProjectBrowserDirectoryItem)
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
571 ):
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
572 dn = itm.dirName()
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
573 else:
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
574 dn = ""
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
575
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
576 filename, ok = EricPathPickerDialog.getStrPath(
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
577 self,
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
578 self.tr("New protocol file"),
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
579 self.tr("Enter the path of the new protocol file:"),
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
580 mode=EricPathPickerModes.SAVE_FILE_ENSURE_EXTENSION_MODE,
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
581 strPath=dn,
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
582 defaultDirectory=dn,
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
583 filters=self.project.getFileCategoryFilters(
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
584 categories=["PROTOCOLS"], withAll=False
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
585 ),
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
586 )
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
587 if ok:
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
588 if not os.path.splitext(filename)[1]:
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
589 filename += ".proto"
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
590
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
591 if os.path.exists(filename):
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
592 EricMessageBox.critical(
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
593 self,
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
594 self.tr("New protocol file"),
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
595 self.tr(
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
596 "<p>The file <b>{0}</b> already exists. The action will be"
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
597 " aborted.</p>"
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
598 ).format(filename),
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
599 )
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
600 return
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
601
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
602 try:
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
603 with open(filename, "w") as f:
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
604 f.write("// {0}\n".format(self.project.getRelativePath(filename)))
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
605 f.write('syntax = "proto2";\n')
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
606 except OSError as err:
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
607 EricMessageBox.critical(
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
608 self,
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
609 self.tr("New protocol file"),
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
610 self.tr(
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
611 "<p>The file <b>{0}</b> could not be created. Aborting...</p>"
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
612 "<p>Reason: {1}</p>"
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
613 ).format(filename, str(err)),
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
614 )
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
615 return
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
616
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
617 self.project.appendFile(filename)
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
618 self.sourceFile[str].emit(filename)
5e9a61e7d7d0 Added the context menu action "New protocol file..." to give a more concise way to create a new protocol file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
619
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
620 def __addProtocolFiles(self):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
621 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
622 Private method to add protocol files to the project.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
623 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
624 itm = self.model().item(self.currentIndex())
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
625 if isinstance(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
626 itm, (ProjectBrowserFileItem, BrowserClassItem, BrowserMethodItem)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
627 ):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
628 dn = os.path.dirname(itm.fileName())
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
629 elif isinstance(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
630 itm, (ProjectBrowserSimpleDirectoryItem, ProjectBrowserDirectoryItem)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
631 ):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
632 dn = itm.dirName()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
633 else:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
634 dn = None
23
7bfac64d06ff Fixed an issue related to adding files and directories to a project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
635 self.project.addFiles("PROTOCOLS", dn)
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
637 def __addProtocolsDirectory(self):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
638 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
639 Private method to add protocol files of a directory to the project.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
640 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
641 itm = self.model().item(self.currentIndex())
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
642 if isinstance(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
643 itm, (ProjectBrowserFileItem, BrowserClassItem, BrowserMethodItem)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
644 ):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
645 dn = os.path.dirname(itm.fileName())
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
646 elif isinstance(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
647 itm, (ProjectBrowserSimpleDirectoryItem, ProjectBrowserDirectoryItem)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
648 ):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
649 dn = itm.dirName()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
650 else:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
651 dn = None
23
7bfac64d06ff Fixed an issue related to adding files and directories to a project.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
652 self.project.addDirectory("PROTOCOLS", dn)
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
653
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
654 def __deleteFile(self):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
655 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
656 Private method to delete files from the project.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
657 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
658 itmList = self.getSelectedItems()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
659
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
660 files = []
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
661 fullNames = []
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
662 for itm in itmList:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
663 fn2 = itm.fileName()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
664 fullNames.append(fn2)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
665 fn = self.project.getRelativePath(fn2)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
666 files.append(fn)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
667
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
668 dlg = DeleteFilesConfirmationDialog(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
669 self.parent(),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
670 self.tr("Delete Protocols"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
671 self.tr(
34
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
672 "Do you really want to delete these protocol files from the project?"
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
673 ),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
674 files,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
675 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
676
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
677 if dlg.exec() == QDialog.DialogCode.Accepted:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
678 for fn2, fn in zip(fullNames, files):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
679 self.closeSourceWindow.emit(fn2)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
680 self.project.deleteFile(fn)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
681
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
682 ###########################################################################
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
683 ## Methods to handle the various compile commands
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
684 ###########################################################################
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
685
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
686 def __getCompilerCommand(self, grpc):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
687 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
688 Private method to get the compiler command.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
689
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
690 @param grpc flag indicating to get a gRPC command
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
691 @type bool
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
692 @return tuple giving the executable and its parameter list
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
693 @rtype tuple of (str, list of str)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
694 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
695 exe = None
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
696 exeArgs = []
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
697
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
698 if grpc:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
699 env = self.__plugin.getPreferences("grpcPythonEnv")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
700 exe = ericApp().getObject("VirtualEnvManager").getVirtualenvInterpreter(env)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
701 if not exe:
12
8ddcd9d47bdf Changed some import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
702 exe = PythonUtilities.getPythonExecutable()
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
703 exeArgs = ["-m", "grpc_tools.protoc"]
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
704 else:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
705 exe = self.__plugin.getPreferences("protoc")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
706 if exe == "":
12
8ddcd9d47bdf Changed some import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
707 exe = "protoc.exe" if OSUtilities.isWindowsPlatform() else "protoc"
8ddcd9d47bdf Changed some import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
708 if not FileSystemUtilities.isinpath(exe):
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
709 exe = None
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
710
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
711 return exe, exeArgs
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
712
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
713 def __readStdout(self):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
714 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
715 Private slot to handle the readyReadStandardOutput signal of the
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
716 protoc process.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
717 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
718 if self.compileProc is None:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
719 return
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
720
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
721 ioEncoding = Preferences.getSystem("IOEncoding")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
722
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
723 self.compileProc.setReadChannel(QProcess.ProcessChannel.StandardOutput)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
724 while self.compileProc and self.compileProc.canReadLine():
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
725 s = "protoc: "
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
726 output = str(self.compileProc.readLine(), ioEncoding, "replace")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
727 s += output
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
728 self.appendStdout.emit(s)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
729
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
730 def __readStderr(self):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
731 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
732 Private slot to handle the readyReadStandardError signal of the
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
733 protoc process.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
734 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
735 if self.compileProc is None:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
736 return
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
737
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
738 ioEncoding = Preferences.getSystem("IOEncoding")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
739
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
740 self.compileProc.setReadChannel(QProcess.ProcessChannel.StandardError)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
741 while self.compileProc and self.compileProc.canReadLine():
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
742 s = "protoc: "
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
743 error = str(self.compileProc.readLine(), ioEncoding, "replace")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
744 s += error
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
745 self.appendStderr.emit(s)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
746
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
747 def __compileProtoDone(self, exitCode, exitStatus, grpc):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
748 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
749 Private slot to handle the finished signal of the protoc process.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
750
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
751 @param exitCode exit code of the process
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
752 @type int
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
753 @param exitStatus exit status of the process
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
754 @type QProcess.ExitStatus
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
755 @param grpc flag indicating to compile as gRPC files
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
756 @type bool
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
757 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
758 self.__compileRunning = False
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
759 ui = ericApp().getObject("UserInterface")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
760 if exitStatus == QProcess.ExitStatus.NormalExit and exitCode == 0:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
761 path = os.path.dirname(self.__protoFile)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
762 fileList = glob.glob(os.path.join(path, "*_pb2.py"))
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
763 if grpc:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
764 fileList += glob.glob(os.path.join(path, "*_pb2_grpc.py"))
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
765 for file in fileList:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
766 self.project.appendFile(file)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
767 if grpc:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
768 icon = EricPixmapCache.getPixmap("gRPC48")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
769 else:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
770 icon = EricPixmapCache.getPixmap("protobuf48")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
771 ui.showNotification(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
772 icon,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
773 self.tr("Protocol Compilation"),
34
41070d80eb1f - Added context menu entries to show the directory path of an item in an external file manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
774 self.tr("The compilation of the protocol file was successful."),
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
775 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
776 else:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
777 if grpc:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
778 icon = EricPixmapCache.getPixmap(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
779 os.path.join(os.path.dirname(__file__), "icons", "gRPC48")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
780 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
781 else:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
782 icon = EricPixmapCache.getPixmap(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
783 os.path.join(os.path.dirname(__file__), "icons", "protobuf48")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
784 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
785 ui.showNotification(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
786 icon,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
787 self.tr("Protocol Compilation"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
788 self.tr("The compilation of the protocol file failed."),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
789 kind=NotificationTypes.CRITICAL,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
790 timeout=0,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
791 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
792 self.compileProc = None
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
793
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
794 def __compileProto(self, fn, noDialog=False, progress=None, grpc=False):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
795 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
796 Private method to compile a .proto file to Python.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
797
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
798 @param fn filename of the .proto file to be compiled
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
799 @type str
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
800 @param noDialog flag indicating silent operations
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
801 @type bool
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
802 @param progress reference to the progress dialog
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
803 @type EricProgressDialog
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
804 @param grpc flag indicating to compile as gRPC files
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
805 @type bool
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
806 @return reference to the compile process
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
807 @rtype QProcess
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
808 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
809 exe, exeArgs = self.__getCompilerCommand(grpc)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
810 if exe:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
811 self.compileProc = QProcess()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
812 args = []
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
813
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
814 fn = os.path.join(self.project.ppath, fn)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
815 self.__protoFile = fn
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
816
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
817 srcPath = os.path.dirname(fn)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
818 args.append("--proto_path={0}".format(srcPath))
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
819 args.append("--python_out={0}".format(srcPath))
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
820 if grpc:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
821 args.append("--grpc_python_out={0}".format(srcPath))
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
822 args.append(fn)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
823
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
824 self.compileProc.finished.connect(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
825 lambda c, s: self.__compileProtoDone(c, s, grpc)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
826 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
827 self.compileProc.readyReadStandardOutput.connect(self.__readStdout)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
828 self.compileProc.readyReadStandardError.connect(self.__readStderr)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
829
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
830 self.noDialog = noDialog
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
831 self.compileProc.start(exe, exeArgs + args)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
832 procStarted = self.compileProc.waitForStarted(5000)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
833 if procStarted:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
834 self.__compileRunning = True
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
835 return self.compileProc
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
836 else:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
837 self.__compileRunning = False
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
838 if progress is not None:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
839 progress.cancel()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
840 EricMessageBox.critical(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
841 self,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
842 self.tr("Process Generation Error"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
843 self.tr(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
844 "<p>Could not start {0}.<br>"
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
845 "Ensure that it is in the search path.</p>"
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
846 ).format(exe),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
847 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
848 return None
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
849 else:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
850 EricMessageBox.critical(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
851 self,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
852 self.tr("Compiler Invalid"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
853 self.tr("The configured compiler is invalid."),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
854 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
855 return None
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
856
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
857 def __compileProtocol(self, grpc=False):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
858 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
859 Private method to compile a protocol to Python.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
860
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
861 @param grpc flag indicating to compile as gRPC files
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
862 @type bool
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
863 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
864 if self.__getCompilerCommand(grpc)[0] is not None:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
865 itm = self.model().item(self.currentIndex())
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
866 fn2 = itm.fileName()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
867 fn = self.project.getRelativePath(fn2)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
868 self.__compileProto(fn, grpc=grpc)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
869
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
870 def __compileAllProtocols(self, grpc=False):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
871 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
872 Private method to compile all protocols to Python.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
873
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
874 @param grpc flag indicating to compile as gRPC files
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
875 @type bool
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
876 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
877 if self.__getCompilerCommand(grpc)[0] is not None:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
878 numProtos = len(self.project.getProjectData(dataKey="PROTOCOLS"))
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
879 progress = EricProgressDialog(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
880 self.tr("Compiling Protocols..."),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
881 self.tr("Abort"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
882 0,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
883 numProtos,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
884 self.tr("%v/%m Protocols"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
885 self,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
886 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
887 progress.setModal(True)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
888 progress.setMinimumDuration(0)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
889 progress.setWindowTitle(self.tr("Protocols"))
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
890
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
891 for prog, fn in enumerate(self.project.getProjectData(dataKey="PROTOCOLS")):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
892 progress.setValue(prog)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
893 if progress.wasCanceled():
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
894 break
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
895 proc = self.__compileProto(fn, True, progress, grpc=grpc)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
896 if proc is not None:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
897 while proc.state() == QProcess.ProcessState.Running:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
898 QThread.msleep(100)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
899 QApplication.processEvents()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
900 else:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
901 break
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
902 progress.setValue(numProtos)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
903
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
904 def __compileSelectedProtocols(self, grpc=False):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
905 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
906 Private method to compile selected protocols to Python.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
907
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
908 @param grpc flag indicating to compile as gRPC files
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
909 @type bool
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
910 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
911 if self.__getCompilerCommand(grpc)[0] is not None:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
912 items = self.getSelectedItems()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
913
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
914 files = [self.project.getRelativePath(itm.fileName()) for itm in items]
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
915 numProtos = len(files)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
916 progress = EricProgressDialog(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
917 self.tr("Compiling Protocols..."),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
918 self.tr("Abort"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
919 0,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
920 numProtos,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
921 self.tr("%v/%m Protocols"),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
922 self,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
923 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
924 progress.setModal(True)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
925 progress.setMinimumDuration(0)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
926 progress.setWindowTitle(self.tr("Protocols"))
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
927
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
928 for prog, fn in enumerate(files):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
929 progress.setValue(prog)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
930 if progress.wasCanceled():
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
931 break
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
932 proc = self.__compileProto(fn, True, progress, grpc=grpc)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
933 if proc is not None:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
934 while proc.state() == QProcess.ProcessState.Running:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
935 QThread.msleep(100)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
936 QApplication.processEvents()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
937 else:
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
938 break
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
939 progress.setValue(numProtos)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
940
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
941 def __configureProtobuf(self):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
942 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
943 Private method to open the configuration dialog.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
944 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
945 ericApp().getObject("UserInterface").showPreferences("protobufPage")

eric ide

mercurial