ExtensionProtobuf/ProjectProtocolsBrowser.py

Tue, 20 Dec 2022 15:01:13 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 20 Dec 2022 15:01:13 +0100
changeset 12
8ddcd9d47bdf
parent 8
24fdd6e43cd7
child 22
ed2d8f5eaa66
permissions
-rw-r--r--

Changed some import statements.

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
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3 # Copyright (c) 2017 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
7157a39d4a0f First incarnation 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
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 from eric7.EricWidgets import EricMessageBox
7157a39d4a0f First incarnation 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
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 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
24 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
25 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
26 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
27 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
28 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
29 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
30 )
7157a39d4a0f First incarnation 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 from eric7.Project.ProjectBrowserRepositoryItem import ProjectBrowserRepositoryItem
12
8ddcd9d47bdf Changed some import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
32 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
33 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
34 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
35 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
36 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
37 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
38 )
7157a39d4a0f First incarnation 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 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
40 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
41
7157a39d4a0f First incarnation 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 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
44 """
7157a39d4a0f First incarnation 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 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
46
7157a39d4a0f First incarnation 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 @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
48 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
49 @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
50 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
51 @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
52 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
53 """
7157a39d4a0f First incarnation 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 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
56 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
57 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
58
7157a39d4a0f First incarnation 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 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
60
7157a39d4a0f First incarnation 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 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
62 """
7157a39d4a0f First incarnation 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 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
64
7157a39d4a0f First incarnation 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 @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
66 @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
67 @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
68 @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
69 """
7157a39d4a0f First incarnation 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 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
71 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
72
7157a39d4a0f First incarnation 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 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
74
7157a39d4a0f First incarnation 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 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
76 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
77 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
78 ]
7157a39d4a0f First incarnation 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 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
81
7157a39d4a0f First incarnation 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 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
83 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
84 """<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
85 """<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
86 """ 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
87 """ 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
88 )
7157a39d4a0f First incarnation 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 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
92
7157a39d4a0f First incarnation 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 # 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
94 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
95 "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
96 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
97 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
98 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
99 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
100 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
101 ),
7157a39d4a0f First incarnation 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 # 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
105 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
106 "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
107 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
108 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
109 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
110 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
111 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
112 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
113 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
114 ),
7157a39d4a0f First incarnation 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 # 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
118 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
119 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
120 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
121 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
122 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
123 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
124 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
125
7157a39d4a0f First incarnation 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 # 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
127 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
128
7157a39d4a0f First incarnation 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 # 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
130 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
131 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
132 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
133 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
134 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
135
7157a39d4a0f First incarnation 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 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
137 """
7157a39d4a0f First incarnation 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 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
139 """
7157a39d4a0f First incarnation 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 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
141 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
142
7157a39d4a0f First incarnation 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 # 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
144 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
145 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
146 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
147 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
148 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
149
7157a39d4a0f First incarnation 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 # 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
151 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
152
7157a39d4a0f First incarnation 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 # 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
154 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
155 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
156 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
157 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
158 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
159 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
160 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
161
7157a39d4a0f First incarnation 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 # 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
163 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
164
7157a39d4a0f First incarnation 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 # 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
166 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
167
7157a39d4a0f First incarnation 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 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
169 """
7157a39d4a0f First incarnation 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 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
171
7157a39d4a0f First incarnation 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 @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
173 @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
174 """
7157a39d4a0f First incarnation 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 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
176 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
177 )
7157a39d4a0f First incarnation 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 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
180 """
7157a39d4a0f First incarnation 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 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
182 """
7157a39d4a0f First incarnation 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 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
184 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
185 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
186 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
187
7157a39d4a0f First incarnation 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 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
189 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
190 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
191 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
192 )
7157a39d4a0f First incarnation 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 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
194 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
195 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
196 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
197 )
7157a39d4a0f First incarnation 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 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
199 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
200 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
201 )
7157a39d4a0f First incarnation 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 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
203 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
204 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
205 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
206 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
207 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
208 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
209 )
7157a39d4a0f First incarnation 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 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
211 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
212 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
213 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
214 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
215 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
216 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
217 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 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
219 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
220 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
221 )
7157a39d4a0f First incarnation 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 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
223 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
224 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
225 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 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
227 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
228 )
8
24fdd6e43cd7 Added a `Collapse all files` entry to the context menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
229 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
230 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
231 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
232 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
233 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
234 )
7157a39d4a0f First incarnation 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.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
237 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
238 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
239 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
240 )
7157a39d4a0f First incarnation 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.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
242 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
243 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
244 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
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.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
247 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
248 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
249 )
7157a39d4a0f First incarnation 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 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
251 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
252 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
253 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
254 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
255 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
256 )
7157a39d4a0f First incarnation 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.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
258 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
259 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
260 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
261 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
262 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
263 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
264
7157a39d4a0f First incarnation 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.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
266 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
267 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
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.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
270 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
271 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
272 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
273 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 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
275 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
276 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
277 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 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
279 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
280 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
281 )
7157a39d4a0f First incarnation 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 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
283 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
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("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
286 )
8
24fdd6e43cd7 Added a `Collapse all files` entry to the context menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
287 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
288 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
289 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
290 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
291 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
292 )
7157a39d4a0f First incarnation 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.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
294
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 # 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
296 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
297 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
298 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
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.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
301 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
302 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
303 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
304 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 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
306 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
307 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
308 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
309 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
310 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
311 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
312 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
313 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
314 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
315 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
316 )
8
24fdd6e43cd7 Added a `Collapse all files` entry to the context menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
317 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
318 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
319 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
320 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
321 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
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
7157a39d4a0f First incarnation 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.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
325 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
326 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
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.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
329 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
330 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
331 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
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 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
334 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
335 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
336 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
337 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
338 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
339 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
340 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
341 )
7157a39d4a0f First incarnation 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.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
343 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
344 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
345 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
346 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
347 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
348 )
8
24fdd6e43cd7 Added a `Collapse all files` entry to the context menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
349 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
350 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
351 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
352 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
353 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
354 )
7157a39d4a0f First incarnation 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.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
357 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
358 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
359 )
7157a39d4a0f First incarnation 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 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
361 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
362 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
363 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
364 )
7157a39d4a0f First incarnation 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.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
366 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
367 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 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
369 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
370 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
371 )
7157a39d4a0f First incarnation 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.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
373 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
374 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
375 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 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
377 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
378 )
8
24fdd6e43cd7 Added a `Collapse all files` entry to the context menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
379 self.dirMultiMenu.addAction(
24fdd6e43cd7 Added a `Collapse all files` entry to the context menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
380 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
381 )
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
382 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
383 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
384 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
385 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
386 )
7157a39d4a0f First incarnation 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
7157a39d4a0f First incarnation 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.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
389 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
390 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
391 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
392 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
393 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
394
7157a39d4a0f First incarnation 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 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
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 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
398
7157a39d4a0f First incarnation 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 @param coord the position of the mouse pointer (QPoint)
7157a39d4a0f First incarnation 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 """
7157a39d4a0f First incarnation 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 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
402 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
403
7157a39d4a0f First incarnation 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 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
405 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
406 [
7157a39d4a0f First incarnation 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 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
408 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
409 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
410 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
411 ]
7157a39d4a0f First incarnation 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 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
414 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
415 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
416 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
417 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
418 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
419 [
7157a39d4a0f First incarnation 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 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
421 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
422 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
423 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
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 )
7157a39d4a0f First incarnation 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 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
427
7157a39d4a0f First incarnation 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 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
429 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
430 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
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 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
433 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
434 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
435 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
436 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
437 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
438 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
439 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
440 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
441 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
442 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
443 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
444 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
445 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
446 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
447 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
448 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
449 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
450 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
451 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
452 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
453 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
454
7157a39d4a0f First incarnation 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 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
456 """
7157a39d4a0f First incarnation 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 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
458 """
7157a39d4a0f First incarnation 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 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
460
7157a39d4a0f First incarnation 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 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
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 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
464 """
7157a39d4a0f First incarnation 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 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
466 """
7157a39d4a0f First incarnation 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 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
468
7157a39d4a0f First incarnation 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 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
470
7157a39d4a0f First incarnation 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 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
472 """
7157a39d4a0f First incarnation 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 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
474 """
7157a39d4a0f First incarnation 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 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
476
7157a39d4a0f First incarnation 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 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
478
7157a39d4a0f First incarnation 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 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
480 """
7157a39d4a0f First incarnation 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 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
482 """
7157a39d4a0f First incarnation 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 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
484
7157a39d4a0f First incarnation 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.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
486
7157a39d4a0f First incarnation 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 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
488 """
7157a39d4a0f First incarnation 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 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
490 """
7157a39d4a0f First incarnation 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 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
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 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
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 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
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 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
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 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
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 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
502 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
503 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
504 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
505 ]
7157a39d4a0f First incarnation 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
7157a39d4a0f First incarnation 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 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
509 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
510 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
511 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
512 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
513 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
514 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
515 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
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 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
518 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
519 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
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
7157a39d4a0f First incarnation 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 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
523 """
7157a39d4a0f First incarnation 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 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
525 """
7157a39d4a0f First incarnation 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 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
527 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
528 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
529 ):
7157a39d4a0f First incarnation 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 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
531 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
532 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
533 ):
7157a39d4a0f First incarnation 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 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
535 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
536 dn = 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
537 self.project.addFiles("protocol", dn)
7157a39d4a0f First incarnation 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 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
540 """
7157a39d4a0f First incarnation 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 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
542 """
7157a39d4a0f First incarnation 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 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
544 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
545 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
546 ):
7157a39d4a0f First incarnation 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 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
548 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
549 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
550 ):
7157a39d4a0f First incarnation 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 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
552 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
553 dn = 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
554 self.project.addDirectory("protocol", dn)
7157a39d4a0f First incarnation 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
7157a39d4a0f First incarnation 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 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
557 """
7157a39d4a0f First incarnation 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 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
559 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
560 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
561
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
562 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
563 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
564 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
565 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
566 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
567 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
568 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
569
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570 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
571 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
572 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
573 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
574 "Do you really want to delete these protocol 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
575 ),
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
576 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
577 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
578
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
579 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
580 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
581 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
582 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
583
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
584 ###########################################################################
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
585 ## 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
586 ###########################################################################
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
587
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
588 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
589 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
590 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
591
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
592 @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
593 @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
594 @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
595 @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
596 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
597 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
598 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
599
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
600 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
601 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
602 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
603 if not exe:
12
8ddcd9d47bdf Changed some import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
604 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
605 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
606 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
607 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
608 if exe == "":
12
8ddcd9d47bdf Changed some import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
609 exe = "protoc.exe" if OSUtilities.isWindowsPlatform() else "protoc"
8ddcd9d47bdf Changed some import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
610 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
611 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
612
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
613 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
614
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
615 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
616 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
617 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
618 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
619 """
7157a39d4a0f First incarnation 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 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
621 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
622
7157a39d4a0f First incarnation 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 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
624
7157a39d4a0f First incarnation 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 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
626 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
627 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
628 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
629 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
630 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
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 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
633 """
7157a39d4a0f First incarnation 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 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
635 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
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 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
638 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
639
7157a39d4a0f First incarnation 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 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
641
7157a39d4a0f First incarnation 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 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
643 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
644 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
645 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
646 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
647 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
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 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
650 """
7157a39d4a0f First incarnation 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 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
652
7157a39d4a0f First incarnation 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 @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
654 @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
655 @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
656 @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
657 @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
658 @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
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 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
661 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
662 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
663 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
664 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
665 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
666 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
667 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
668 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
669 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
670 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
671 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
672 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
673 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
674 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
675 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
676 self.tr("The compilation of the protocol file was" " successful."),
7157a39d4a0f First incarnation 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 )
7157a39d4a0f First incarnation 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 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
679 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
680 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
681 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
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 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
684 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
685 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
686 )
7157a39d4a0f First incarnation 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 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
688 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
689 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
690 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
691 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
692 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
693 )
7157a39d4a0f First incarnation 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 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
695
7157a39d4a0f First incarnation 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 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
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 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
699
7157a39d4a0f First incarnation 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 @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
701 @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
702 @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
703 @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
704 @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
705 @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
706 @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
707 @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
708 @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
709 @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
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 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
712 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
713 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
714 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
715
7157a39d4a0f First incarnation 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 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
717 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
718
7157a39d4a0f First incarnation 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 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
720 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
721 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
722 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
723 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
724 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
725
7157a39d4a0f First incarnation 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 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
727 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
728 )
7157a39d4a0f First incarnation 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 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
730 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
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 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
733 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
734 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
735 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
736 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
737 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
738 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
739 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
740 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
741 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
742 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
743 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
744 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
745 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
746 "<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
747 "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
748 ).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
749 )
7157a39d4a0f First incarnation 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 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
751 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
752 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
753 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
754 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
755 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
756 )
7157a39d4a0f First incarnation 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 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
758
7157a39d4a0f First incarnation 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 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
760 """
7157a39d4a0f First incarnation 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 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
762
7157a39d4a0f First incarnation 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 @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
764 @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
765 """
7157a39d4a0f First incarnation 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 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
767 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
768 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
769 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
770 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
771
7157a39d4a0f First incarnation 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 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
773 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
774 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
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 @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
777 @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
778 """
7157a39d4a0f First incarnation 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 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
780 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
781 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
782 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
783 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
784 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
785 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
786 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
787 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
788 )
7157a39d4a0f First incarnation 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 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
790 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
791 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
792
7157a39d4a0f First incarnation 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 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
794 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
795 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
796 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
797 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
798 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
799 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
800 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
801 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
802 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
803 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
804 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
805
7157a39d4a0f First incarnation 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 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
807 """
7157a39d4a0f First incarnation 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 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
809
7157a39d4a0f First incarnation 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 @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
811 @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
812 """
7157a39d4a0f First incarnation 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 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
814 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
815
7157a39d4a0f First incarnation 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 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
817 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
818 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
819 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
820 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
821 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
822 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
823 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
824 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
825 )
7157a39d4a0f First incarnation 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 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
827 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
828 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
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 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
831 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
832 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
833 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
834 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
835 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
836 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
837 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
838 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
839 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
840 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
841 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
842
7157a39d4a0f First incarnation 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 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
844 """
7157a39d4a0f First incarnation 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 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
846 """
7157a39d4a0f First incarnation 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 ericApp().getObject("UserInterface").showPreferences("protobufPage")

eric ide

mercurial