Coverage for src/robotide/editor/macroeditors.py: 60%
76 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-06 10:40 +0100
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-06 10:40 +0100
1# Copyright 2008-2015 Nokia Networks
2# Copyright 2016- Robot Framework Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
16import wx 1ab
18from ..publish.messages import RideItemNameChanged 1ab
19from ..usages.UsageRunner import Usages 1ab
20from .editors import _RobotTableEditor, FindUsagesHeader 1ab
21from .kweditor import KeywordEditor 1ab
24class TestCaseEditor(_RobotTableEditor): 1ab
25 __test__ = False 1ab
26 _settings_open_id = 'test case settings open' 1ab
28 def _populate(self): 1ab
29 self.header = self._create_header(self.controller.name)
30 self.sizer.Add(self.header, 0, wx.EXPAND | wx.ALL, 5)
31 self._add_settings()
32 self.sizer.Add((0, 10))
33 self._create_kweditor()
34 self.plugin.subscribe(self._name_changed, RideItemNameChanged)
36 def _create_kweditor(self): 1ab
37 self.kweditor = KeywordEditor(self, self.controller, self._tree)
38 self.sizer.Add(self.kweditor, 1, wx.EXPAND | wx.ALL, 2)
39 self._editors.append(self.kweditor)
41 def _name_changed(self, message): 1ab
42 # print(f"DEBUG: macroeditors.py TestCaseEditor _name_changed ENTER {message}\n")
43 if message.item == self.controller:
44 self.header.SetLabel(message.item.name)
45 # print(f"DEBUG: macroeditors.py TestCaseEditor _name_changed DONE {message.item.name=} {self.controller}")
47 def close(self): 1ab
48 for editor in self._editors:
49 editor.close()
50 super().close()
51 self.plugin.unsubscribe(self._name_changed, RideItemNameChanged)
53 def save(self): 1ab
54 self.kweditor.save() 1c
56 def undo(self): 1ab
57 # DEBUG: On Linux we were having double Ctrl-Z action
58 # self.kweditor.on_undo()
59 pass
61 def redo(self): 1ab
62 self.kweditor.on_redo() 1c
64 def cut(self): 1ab
65 self.kweditor.on_cut() 1c
67 def copy(self): 1ab
68 self.kweditor.on_copy() 1c
70 def paste(self): 1ab
71 self.kweditor.on_paste() 1c
73 def insert(self): 1ab
74 self.kweditor.on_insert() 1c
76 def insert_cells(self): 1ab
77 self.kweditor.on_insert_cells() 1c
79 def delete_cells(self): 1ab
80 # print("DEBUG macro delete cells ")
81 self.kweditor.on_delete_cells() 1c
83 def insert_rows(self): 1ab
84 self.kweditor.on_insert_rows(None) # DEBUG python 3 1c
86 def delete_rows(self): 1ab
87 self.kweditor.on_delete_rows(None) # DEBUG python 3 1c
89 def on_move_rows_up(self): 1ab
90 self.kweditor.on_move_rows_up()
92 def on_move_rows_down(self): 1ab
93 self.kweditor.on_move_rows_down()
95 def delete(self): 1ab
96 self.kweditor.on_delete() 1c
98 def comment_rows(self): 1ab
99 self.kweditor.on_comment_rows()
101 def uncomment_rows(self): 1ab
102 self.kweditor.on_uncomment_rows()
104 def sharp_comment_rows(self): 1ab
105 self.kweditor.on_sharp_comment_rows()
107 def sharp_uncomment_rows(self): 1ab
108 self.kweditor.on_sharp_uncomment_rows()
110 def comment_cells(self): 1ab
111 self.kweditor.on_comment_cells(None)
113 def uncomment_cells(self): 1ab
114 self.kweditor.on_uncomment_cells(None)
116 def show_content_assist(self): 1ab
117 self.kweditor.show_content_assist() 1c
120class UserKeywordEditor(TestCaseEditor): 1ab
121 _settings_open_id = 'user keyword settings open' 1ab
123 def _create_header(self, text, readonly=False): 1ab
124 def cb(event):
125 __ = event
126 Usages(self.controller, self._tree.highlight).show()
127 return FindUsagesHeader(self, text, cb, color_foreground=self.color_secondary_foreground,
128 color_background=self.color_secondary_background)