ExtensionProtobuf/ProjectProtocolsBrowser.py

Sat, 16 Dec 2023 17:44:35 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 16 Dec 2023 17:44:35 +0100
changeset 39
834f02706a31
parent 34
41070d80eb1f
child 40
c187d961ee3a
permissions
-rw-r--r--

Created global tag <release-10.1.8>.

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

eric ide

mercurial